//#define _GLIBCXX_DEBUG #include using namespace std; #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater>; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} constexpr int64_t safe_mod(int64_t x, int64_t m) { x %= m; if(x < 0) x += m; return x; } constexpr pair inv_gcd(int64_t a, int64_t b) { a = safe_mod(a, b); if(a == 0) return {b, 0}; int64_t s = b, t = a; int64_t m0 = 0, m1 = 1; while(t) { int64_t u = s/t; s -= t*u; m0 -= m1*u; int64_t tmp = s; s = t; t = tmp; tmp = m0; m0 = m1; m1 = tmp; } if(m0 < 0) m0 += b/s; return {s, m0}; } // 最初に d_mint::set_mod(m) を行う struct d_mint { struct barrett { unsigned int _m; uint64_t im; barrett(unsigned int m):_m(m), im(uint64_t(-1)/m + 1) {} unsigned int umod() const {return _m;} unsigned int mul(unsigned int a, unsigned int b) const { uint64_t z = a; z *= b; uint64_t x = uint64_t(((unsigned __int128)(z)*im) >> 64); unsigned int v = (unsigned int)(z-x*_m); if(_m <= v) v += _m; return v; } }; unsigned int x; static barrett bt; static unsigned int umod() {return bt.umod();} static int mod() {return int(bt.umod());} static void set_mod(int m) { assert(1 <= m); bt = barrett(m); } static d_mint raw(int v) { d_mint z; z.x = v; return z; } d_mint() : x(0) {} template d_mint(T v) { int64_t z = int64_t(v % int64_t(mod())); if(z < 0) z += mod(); x = (unsigned int)(z); } d_mint& operator++() { x++; if(x == umod()) x = 0; return *this; } d_mint& operator--() { if(x == 0) x = umod(); x--; return *this; } d_mint operator++(int) { d_mint result = *this; ++*this; return result; } d_mint operator--(int) { d_mint result = *this; --*this; return result; } d_mint& operator+=(const d_mint &rhs) { x += rhs.x; if(x >= umod()) x -= umod(); return *this; } d_mint& operator-=(const d_mint &rhs) { x += mod() - rhs.x; if(x >= umod()) x -= umod(); return *this; } d_mint& operator*=(const d_mint &rhs) { x = bt.mul(x, rhs.x); return *this; } d_mint& operator/=(const d_mint& rhs) { return *this = *this * rhs.inv(); } d_mint operator+() const {return *this;} d_mint operator-() const {return d_mint() - *this;} d_mint pow(int64_t n) const { assert(0 <= n); d_mint z = *this, r = 1; while(n) { if(n&1) r *= z; z *= z; n >>= 1; } return r; } d_mint inv() const { auto eg = inv_gcd(x, mod()); assert(eg.first == 1); return eg.second; } friend d_mint operator+(const d_mint &lhs, const d_mint &rhs) { return d_mint(lhs) += rhs; } friend d_mint operator-(const d_mint &lhs, const d_mint &rhs) { return d_mint(lhs) -= rhs; } friend d_mint operator*(const d_mint &lhs, const d_mint &rhs) { return d_mint(lhs) *= rhs; } friend d_mint operator/(const d_mint &lhs, const d_mint &rhs) { return d_mint(lhs) /= rhs; } friend bool operator==(const d_mint &lhs, const d_mint &rhs) { return lhs.x == rhs.x; } friend bool operator!=(const d_mint &lhs, const d_mint &rhs) { return lhs.x != rhs.x; } friend istream &operator>>(istream &is, d_mint &x) {return is >> x.x;} friend ostream &operator<<(ostream &os, const d_mint &x) {return os << x.x;} }; d_mint::barrett d_mint::bt = 998244353; //head int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) { int v, x; cin >> v >> x; d_mint::set_mod(v*x+1); vi ans(x); int ptr = 0; for(int i = 1; i < v*x+1; i++) if(d_mint(i).pow(x) == 1) ans[ptr++] = i; rep(i, x) cout << ans[i] << (i == x-1?'\n':' '); } }