#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef pair PII; typedef vector VI; typedef vector VPII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef double DB; #define pb push_back #define mset(a, b) memset(a, b, sizeof a) #define all(x) (x).begin(), (x).end() #define bit(x) (1 << (x)) #define bitl(x) (1LL << (x)) #define sqr(x) ((x) * (x)) #define sz(x) ((int)(x.size())) #define counti(x) (__builtin_popcount(x)) #define clz(x) (__builtin_clz(x)) #define ctz(x) (__builtin_ctz(x)) #define countl(x) (__builtin_popcountll(x)) #define rep(i, n) for (int (i) = 0; (i) < (int)(n); ++(i)) #define Error(x) cout << #x << " = " << endl #define X first #define Y second template inline void chkmax(T& x, U y) { if (x < y) x = y; } template inline void chkmin(T& x, U y) { if (y < x) x = y; } long long seed; #define MX 1234567 inline long long RRand(long long l, long long r) { static long long mo=1e9+7, g=78125; return l+((seed*=g)%=mo)%(r-l+1); } LL x[MX], y[MX], a[MX], b[MX]; int n; int main() { int Tcase; for (scanf("%d", &Tcase); Tcase--;) { cin >> n >> seed; LL ans = 0; for (int i = 0; i < n; i++) { x[i] = RRand(-1000000000, 1000000000), y[i] = RRand(-1000000000, 1000000000); a[i] = x[i] + y[i], b[i] = x[i] - y[i]; } ans = *max_element(a, a + n) - *min_element(a, a + n); chkmax(ans, *max_element(b, b + n) - *min_element(b, b + n)); cout << ans << endl; } return 0; }