q-ary polynomial