In this paper we propose a new semi fragile watermarking technique which embeds multivalued watermarks. It is necessary for semi fragile watermarking to assess the degree of tampering correctly. However most previously proposed schemes which use binary watermarks claim an image to be tampered with even for light grade JPEG compression. The proposed scheme embeds multivalued watermarks to wavelet coefficients, which we call q-ary watermarking. In q-ary watermarking we embed each bit of q-ary watermarks into wavelet coefficients, which reside in different wavelet levels to reflect the features of lossy compression. For that purpose we embed significant bits of watermarks to lower frequency components and less significant bits to higher frequency components. Furthermore the wavelet coefficients should have spatial relation. We apply the concept of zero-tree, which is proposed in conjunction with the wavelet based image compression scheme, for selecting such coefficients. Using q-ary watermarking we can evaluate not only the positions or the number of positions of tampering but also the degree of tampering. It is proven that q-ary watermarking can evaluate the degree of JPEG compression more accurately than Kundur-Hatzinakos' scheme for a wide range of JPEG compression ratios.