#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int q;
int n, l, r;

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> q;

	while (q--)
	{
		cin >> n >> l >> r;

		if (l <= 2)
		{
			vector<int> beg = { 1, 2};

			for (int i = l; i <= min(2ll, r); ++i)
				cout << beg[i - 1] << " ";

			l = 3;
		}

		if (l > r)
		{
			cout << endl;
			continue;
		}

		l -= 2;
		r -= 2;

		int cntl = l / 4 + (l % 4 == 0 ? 0 : 1) + 2;
		int lftl = 4 - (l - 1) % 4;

		if (lftl != 0)
		{
			vector<int> beg = { 1, cntl, cntl - 1, cntl };

			for (int i = 4 - lftl; i < min(4ll, r - l + 4 - lftl + 1); ++i)
				cout << beg[i] << " ";

			l += lftl;

			++cntl;
		}

		if (l > r)
		{
			cout << endl;
			continue;
		}

		vector<int> end;

		int cnt = r / 4 + 2 + (r % 4 == 0 ? 0 : 1);
		int lft = r % 4;

		vector<int> tmp = { 1, cnt, cnt - 1, cnt, 1 };

		if (lft != 0)
		{
			--cnt;

			for (int i = 0; i < lft; ++i)
				end.push_back(tmp[i]);

			r -= lft;
		}

		vector<int> rev;

		for (int i = r; i >= l; i -= 4)
		{
			vector<int> add = {cnt, cnt - 1, cnt, 1 };

			for (auto it : add)
				rev.push_back(it);

			--cnt;
		}

		reverse(rev.begin(), rev.end());

		for (auto it : rev)
			cout << it << " ";

		for (auto it : end)
			cout << it << " ";

		cout << endl;
	}
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int q;
int n, l, r;

int get(int x)
{
	int cur = 2;
	int cnt = (sqrt(1ll + 8ll * x / 2ll) - 1ll) / 2ll;

	while (cnt * (cnt + 1) > x)
		--cnt;

	while ((cnt + 1) * (cnt + 2) <= x)
		++cnt;

	if (cnt * (cnt + 1) != x)
		++cnt;

	x -= (cnt - 1) * cnt;

	if (x == 1)
		return 1;

	if (x == 0)
		return cnt + 1;

	--x;

	if (x % 2 == 1)
		return cnt + 1;

	return x / 2 + 1;
}

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> q;

	while (q--)
	{
		cin >> n >> l >> r;

		for (int i = l; i <= r; ++i)
			cout << get(i) << " ";

		cout << endl;
	}
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int q;
int n, l, r;
int mxcnt;
int sz[N];

int binsearch(int fl, int x)
{
	int l = 0;
	int r = fl + 1;

	while (l < r)
	{
		int mid = (l + r) / 2ll;

		if (-mid * max(0ll, (mid - 1)) + fl * mid < x)
			l = mid + 1;
		else
			r = mid;
	}

	return l;
}

int get(int x)
{
	if (n == 2 && x == 3)
		return 1;

	if (n == 3 && x == 7)
		return 1;

	if (x / 2 + x % 2 <= n - 1)
	{
		if (x % 2 == 1)
			return 1;

		return x / 2ll + 1;
	}

	x -= (n - 1) * 2ll;
	int visit = n - 3;

	int firstlen = (visit + 1) * 2ll;
	int cnt = binsearch(firstlen, x) - 1;

	x -= -cnt * max(0ll, (cnt - 1)) + firstlen * cnt;
	int len = firstlen - 2ll * max(0ll, (cnt - 1));
	int cur = cnt + 2;

	if (x == 0 || len < 0)
		return 1;

	if (x % 2 == 1)
		return cur;

	return cur + x / 2;
}

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> q;

	sz[2] = 1ll;

	for (int i = 3; i < N; ++i)
		sz[i] = sz[i - 1] * 2ll;

	while (q--)
	{
		cin >> n >> l >> r;

		for (int i = l; i <= r; ++i)
			cout << get(i) << " ";

		cout << endl;
	}
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int q;
int n, l, r;

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> q;

	while (q--)
	{
		cin >> n >> l >> r;

		if (l <= 2)
		{
			vector<int> beg = { 1, 2};

			for (int i = l; i <= min(2ll, r); ++i)
				cout << beg[i - 1] << " ";

			l = 3;
		}

		if (l > r)
		{
			cout << endl;
			continue;
		}

		l -= 2;
		r -= 2;

		int cntl = (l - 1) / 4 + ((l - 1) % 4 == 0 ? 0 : 1) + 3;
		int lftl = 4 - (l - 1) % 4;

		if (lftl != 0)
		{
			vector<int> beg = { 1, cntl, cntl - 1, cntl };

			for (int i = 4 - lftl; i < min(4ll, r - l + 4 - lftl + 1); ++i)
				cout << beg[i] << " ";

			l += lftl;

			++cntl;
		}

		if (l > r)
		{
			cout << endl;
			continue;
		}

		vector<int> end;

		int cnt = r / 4 + 2 + (r % 4 == 0 ? 0 : 1);
		int lft = r % 4;

		vector<int> tmp = { 1, cnt, cnt - 1, cnt, 1 };

		if (lft != 0)
		{
			--cnt;

			for (int i = 0; i < lft; ++i)
				end.push_back(tmp[i]);
		}

		vector<int> rev;

		for (int i = r; i >= l; i -= 4)
		{
			vector<int> add = {cnt, cnt - 1, cnt, 1 };

			for (auto it : add)
				rev.push_back(it);

			--cnt;
		}

		reverse(rev.begin(), rev.end());

		for (auto it : rev)
			cout << it << " ";

		for (auto it : end)
			cout << it << " ";

		cout << endl;
	}
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <set>
#include <cstdio>
#include <memory>
#include <cmath>
#include <chrono>
#include <random>
#include <map>
#include <sstream>
#include <queue>
#include <cassert>
#include <cstdio>
#define x first
#define y second
#define int long long
#define pii pair<int, int>

using namespace std;

const int N = 1e6 + 10;
const int inf = 1e18;
const int mod = 998244353;

//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int q;
int n, l, r;

int get(int x)
{
	int cur = 2ll;
	int cnt = (sqrt(1ll + 8ll * x / 2ll) - 1ll) / 2ll;

	while (cnt * (cnt + 1ll) > x)
		--cnt;

	while ((cnt + 1ll) * (cnt + 2ll) <= x)
		++cnt;

	if (cnt * (cnt + 1ll) != x)
		++cnt;

	x -= (cnt - 1ll) * cnt;

	if (x == 1ll)
		return 1ll;

	if (x == 0ll)
		return cnt + 1ll;

	--x;

	if (x % 2ll == 1ll)
		return cnt + 1ll;

	return x / 2 + 1ll;
}

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> q;

	while (q--)
	{
		cin >> n >> l >> r;

		for (int i = l; i <= r; ++i)
			cout << get(i) << " ";

		cout << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		vl cur(n);
		mll ans;
		cur[0] = 1;
		for (int i = 1;i < n;i++)
			cur[i] = n - i + 1;
		ll R = min((n - 1) * (n - 1), r);
		ll remaining = n - 1, c = 0, pos = 1;
		for (int i = 0;i < n - 1;i++) {
			if (pos > R) {
				break;
			}
			if (pos + (remaining * 2 - 1) - 1 >= l) {
				for (int j = 0;j < (remaining * 2 - 1);j += 2) {
					ans[j + pos] = cur[c];
				}
				for (int j = 1, p = 2;j < (remaining * 2 - 1);j += 2, p++) {
					ans[j + pos] = p;
				}
			}
			pos += (remaining * 2 - 1);
			remaining--;
			c++;
		}
		ll pp = (n - 1) * (n - 1) + 1;
		for (int i = 0;i < n;i++, pp++)
			ans[pp] = cur[n - 1 - i];
		for (auto x : ans) {
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		}
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		vl cur(n);
		mll ans;
		cur[0] = 1;
		for (ll i = 1;i < n;i++)
			cur[i] = n - i + 1;
		ll R = min((n - 1) * (n - 1), r);
		ll remaining = n - 1, c = 0, pos = 1;
		while (true) {
			if (pos > R) {
				break;
			}
			if (pos + (remaining * 2 - 1) - 1 >= l) {
				for (ll j = 0;j < (remaining * 2 - 1);j += 2) {
					ans[j + pos] = cur[c];
				}
				for (ll j = 1, p = 2;j < (remaining * 2 - 1);j += 2, p++) {
					ans[j + pos] = p;
				}
			}
			pos += (remaining * 2 - 1);
			remaining--;
			c++;
		}
		ll pp = (n - 1) * (n - 1) + 1;
		for (ll i = 0;i < n;i++, pp++)
			ans[pp] = cur[n - 1 - i];
		for (auto x : ans) {
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		}
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		mll ans;
		deque<int> dq;
		for (int i = 1;i <= n;i++)
			dq.pb(i);
		ll left = 1, right = n * (n - 1) + 1;
		for (int i = 0;i < n/2;i++) {
			ll d = 2 * (n - 2 * i - 1);
			if (left + d - 1 >= l && left <= r) {
				for (size_t pos = left, i = 0;i < dq.size() - 1;i++, pos += 2)
					ans[pos] = dq.front();
				for (size_t pos = left + 1, i = 1;i < dq.size();i++, pos += 2)
					ans[pos] = dq[i];
			}
			if (right - d + 3 <= r && right >= l) {
				for (size_t pos = right - d + 3, i = 0;i < dq.size() - 2;i++, pos += 2)
					ans[pos] = dq.back();
				for (size_t pos = right - d + 4, i = 2;i < dq.size() - 1;i++, pos += 2)
					ans[pos] = dq[i];
				ans[right] = dq.front();

			}
			dq.pop_back();
			dq.pop_front();
			left += d;
			right -= (d - 2);
		}
		if (dq.size() == 1) {
			ans[left] = dq.front();
		}
		else if (dq.size() == 2) {
			ans[left] = ans[right] = dq.front();
			ans[left + 1] = dq.back();
		}
		for (auto x : ans)
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		vl cur(n);
		mll ans;
		cur[0] = 1;
		for (int i = 1;i < n;i++)
			cur[i] = n - i + 1;
		ll R = min((n - 1) * (n - 1), r);
		ll remaining = n - 1, c = 0, pos = 1;
		for (int i = 0;i < n - 1;i++) {
			if (pos > R) {
				break;
			}
			if (pos + (remaining * 2 - 1) >= l) {
				for (int j = 0;j < (remaining * 2 - 1);j += 2) {
					ans[j + pos] = cur[c];
				}
				for (int j = 1, p = 2;j < (remaining * 2 - 1);j += 2, p++) {
					ans[j + pos] = p;
				}
			}
			pos += (remaining * 2 - 1);
			remaining--;
			c++;
		}
		for (int i = 0;i < n;i++, pos++)
			ans[pos] = cur[n - 1 - i];
		for (auto x : ans) {
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		}
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		mll ans;
		deque<int> dq;
		for (int i = 1;i <= n;i++)
			dq.pb(i);
		ll left = 1, right = n * (n - 1) + 1;
		for (int i = 0;i < (n - 1)/2;i++) {
			ll d = 2 * (n - 2 * i - 1);
			if (left + d - 1 >= l && left <= r) {
				for (size_t pos = left, i = 0;i < dq.size() - 1;i++, pos += 2)
					ans[pos] = dq.front();
				for (size_t pos = left + 1, i = 1;i < dq.size();i++, pos += 2)
					ans[pos] = dq[i];
			}
			if (right - d + 3 <= r && right >= l) {
				for (size_t pos = right - d + 3, i = 0;i < dq.size() - 2;i++, pos += 2)
					ans[pos] = dq.back();
				for (size_t pos = right - d + 4, i = 2;i < dq.size() - 1;i++, pos += 2)
					ans[pos] = dq[i];
				ans[right] = dq.front();

			}
			dq.pop_back();
			dq.pop_front();
			left += d;
			right -= (d - 2);
		}
		if (dq.size() == 1) {
			ans[left] = dq.front();
		}
		else if (dq.size() == 2) {
			ans[left] = ans[right] = dq.front();
			ans[left + 1] = dq.back();
		}
		for (auto x : ans)
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		vl cur(n);
		mll ans;
		cur[0] = 1;
		for (ll i = 1;i < n;i++)
			cur[i] = n - i + 1;
		ll R = min((n - 1) * (n - 1), r);
		ll remaining = n - 1, c = 0, pos = 1;
		for (ll i = 0;i < n - 1;i++) {
			if (pos > R) {
				break;
			}
			if (pos + (remaining * 2 - 1) - 1 >= l) {
				for (ll j = 0;j < (remaining * 2 - 1);j += 2) {
					ans[j + pos] = cur[c];
				}
				for (ll j = 1, p = 2;j < (remaining * 2 - 1);j += 2, p++) {
					ans[j + pos] = p;
				}
			}
			pos += (remaining * 2 - 1);
			remaining--;
			c++;
		}
		ll pp = (n - 1) * (n - 1) + 1;
		for (ll i = 0;i < n;i++, pp++)
			ans[pp] = cur[n - 1 - i];
		for (auto x : ans) {
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		}
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		vl cur(n);
		mll ans;
		cur[0] = 1;
		for (int i = 1;i < n;i++)
			cur[i] = n - i + 1;
		ll R = min((n - 1) * (n - 1), r);
		ll remaining = n - 1, c = 0, pos = 1;
		for (int i = 0;i < n - 1;i++) {
			if (pos > R) {
				break;
			}
			if (pos + (remaining * 2 - 1) - 1 >= l) {
				for (int j = 0;j < (remaining * 2 - 1);j += 2) {
					ans[j + pos] = cur[c];
				}
				for (int j = 1, p = 2;j < (remaining * 2 - 1);j += 2, p++) {
					ans[j + pos] = p;
				}
			}
			pos += (remaining * 2 - 1);
			remaining--;
			c++;
		}
		for (int i = 0;i < n;i++, pos++)
			ans[pos] = cur[n - 1 - i];
		for (auto x : ans) {
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		}
		cout << '\n';
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	tc {
		ll n, l, r;
		cin >> n >> l >> r;
		mll ans;
		ll cur = 1;
		for (int i = 1;i <= n;i++) {
			ll next_cur = cur + (n - i) * 2;
			if (l < next_cur && r >= cur) {
				for (ll j = i;j < n;j++) {
					ans[cur++] = i;
					ans[cur++] = j + 1;
				}
			}
			cur = next_cur;
		}
		ans[cur] = 1;
		for (auto x : ans)
			if (x.first >= l && x.first <= r)
				cout << x.second << ' ';
		cout << '\n';
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
        }
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        count=l;
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }
        cout<<'\n';
            }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
            //cout<<a[i]<<" ";
        }
        //cout<<'\n';
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        if(rem%2==0)
        no--;
        //cout<<cidx;
        count=l;
        if(cidx>=n-1&&count==r){
                  cout<<1;

              }
              else{
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }}
        cout<<'\n';
            }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
        }
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        count=l;
        if(cidx>=n-1&&count==r){
                  cout<<1;

              }
              else{
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }}
        cout<<'\n';
            }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
            //cout<<a[i]<<" ";
        }
        //cout<<'\n';
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        if(rem%2==0)
        no--;
        //cout<<cidx;
        count=l;
        if(cidx>=n-1&&count==r){
                  cout<<1;

              }

              else{
                  if(rem==0){
                  cidx--;
                  rem = l-a[cidx];
                  no = cidx+1+rem/2;
              }
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }}
        cout<<'\n';
            }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
            //cout<<a[i]<<" ";
        }
        //cout<<'\n';
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        if(rem2%2==0)
        no--;
        //cout<<cidx;
        count=l;
        if(cidx>=n-1&&count==r){
                  cout<<1;

              }
              else{
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }}
        cout<<'\n';
            }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n,r,l,i,sum,rem,no,idx,cidx,count,fidx,rem2,next;
        cin>>n>>l>>r;
        long long int a[n],*low,*high;
        a[0]=0;
        for(i=1;i<n;i++){
            sum = 2*(n-i);
            a[i] = a[i-1]+sum;
            //cout<<a[i]<<" ";
        }
        cout<<'\n';
        low =  upper_bound(a,a+n,l);
        high = upper_bound(a,a+n,r);
        low--;
        high--;
        idx = low-a;
        fidx = high-a;
        cidx=idx;
        rem = l-a[cidx];
        rem2 = r-a[fidx];
        no = cidx+2+rem/2;
        if(rem2%2==0)
        no--;
        //cout<<cidx;
        count=l;
        if(cidx>=n-1&&count==r){
                  cout<<1;

              }
              else{
        while(count<=r){
            //cout<<"curr_idx = "<<cidx<<" ";
              next = (a[cidx+1]>r)?r:a[cidx+1];
              for(;count<=next;count++){
                  if(count%2==0){
                      cout<<no<<" ";
                      no++;
                  }
                  else
                  cout<<(cidx+1)<<" ";
              }
              cidx++;
              if(cidx>=n-1&&count==r){
                  cout<<1;
                  break;
              }
              no = cidx+2;
        }}
        cout<<'\n';
            }
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) <= l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		int j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}
		}

		int cnt = r - l + 1;
		while (cnt != 0) {
			if (cnt != 0) {
				cout << i << ' ';
				--cnt;
			}

			if (cnt != 0) {
				cout << j << ' ';
				--cnt, ++j;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) < l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		ll j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}
		}

		ll cnt = r - l + 1;
		while (cnt != 0) {
			if (cnt != 0) {
				cout << i << ' ';
				--cnt;
			}

			if (cnt != 0) {
				cout << j << ' ';
				--cnt, ++j;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) <= l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		ll j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}
		}

		ll cnt = r - l + 1;
		while (cnt != 0) {
			if (cnt != 0) {
				cout << i << ' ';
				--cnt;
			}

			if (cnt != 0) {
				cout << j << ' ';
				--cnt, ++j;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) < l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		ll j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}

			if (j == n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		while (sum <= r) {
			if (sum <= r) {
				cout << i << ' ';
				++sum;
			}

			if (sum <= r) {
				cout << j << ' ';
				++j, ++sum;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) < l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		ll j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}
		}

		while (sum <= r) {
			if (sum <= r) {
				cout << i << ' ';
				++sum;
			}

			if (sum <= r) {
				cout << j << ' ';
				++j, ++sum;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll mx = n * (n - 1) + 1, cnt = 0, x = 1;
		for (ll i = l; i <= r && i < mx; ++i) {
			while (cnt + 2 * (n - x) < i) {
				cnt += 2 * (n - x);
				++x;
			}

			ll add = i - cnt;
			if (add & 1) {
				cout << x << ' ';
			} else {
				cout << x + (add / 2) << ' ';
			}
		}

		if (r == mx) {
			cout << 1;
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include <bits/stdc++.h>

#define INF 1e18
#define EPS 1e-6
#define pb push_back
#define pause system("pause");
#define exit exit(0)

using namespace std;
using ll = long long;
using ull = unsigned long long;

ll t, n, l, r;

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> l >> r;

		ll sum = 0, i = 1;
		while (sum + 2 * (n - i) < l) {
			if (i == n) {
				i = 1;
				++sum;
				break;
			}

			sum += 2 * (n - i);
			++i;
		}

		ll j = i + 1;
		while (sum != l) {
			if (sum != l) {
				++sum;
			}

			if (sum != l) {
				++sum, ++j;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		while (sum <= r) {
			if (sum <= r) {
				cout << i << ' ';
				++sum;
			}

			if (sum <= r) {
				cout << j << ' ';
				++j, ++sum;
			}

			if (j > n) {
				++i;
				j = i + 1;

				if (i == n) {
					i = 1;
				}
			}
		}

		cout << endl;
	}
	//pause;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            l-=before;
            r-=before;
            vector<int>ans;
            ans.pb(0);
            int k=r;
            for(int j=i;j<=n;j++){
                int curr=j+1;
                while(curr<=n and k>0){
                    ans.pb(j);
                    ans.pb(curr);
                    k-=2;
                    curr++;
                }
                if(k<=0)break;
            }
            if(k>0)ans.pb(1);
            for(int j=l;j<=r;j++){
                cout<<ans[j]<< ' ';
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            l-=before;
            r-=before;
            vector<int>ans;
            ans.pb(0);
            int k=r;
            for(int j=i;j<=n;j++){
                int curr=j+1;
                while(curr<=n and k>0){
                    ans.pb(j);
                    ans.pb(curr);
                    k-=2;
                    curr++;
                }
                if(k<=0)break;
            }
            if(ans[r-1]==n)ans[r]=1;
            for(int j=l;j<=r;j++){
                cout<<ans[j]<< ' ';
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>50*(r-l+1))break;
                }
                if(sz(ans)>50*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            int len=r-l+1;
            l-=before;
            assert(l>=0);
            for(int j=l-1,g=0;g<(len);j++){
                g++;
                assert(j<sz(res));
                cout<<res[j]<<' ';
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>20*(r-l+1))break;
                }
                if(sz(ans)>20*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            int len=r-l+1;
            l-=before;
            assert(l>=0);
            for(int j=l-1,g=0;g<(len);j++){
                g++;
                assert(j<sz(res));
                cout<<res[j]<<' ';
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            l-=before;
            r-=before;
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>10*(r-l+1))break;
                }
                if(sz(ans)>10*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            int len=r-l+1;
            assert(l>0);
            for(int j=l-1,g=0;g<(len);j++){
                g++;
                assert(j<sz(res));
                cout<<res[j]<<' ';
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>3*(r-l+1))break;
                }
                if(sz(ans)>3*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            // see(sz(res));
            // see(r-l+1);
            int len=r-l+1;
            l-=before;
            assert(l>=0);
            for(int j=l-1,g=0;g<(len);j++){
                g++;
                assert(j<sz(res));
                cout<<res[j]<<' ';
                assert(res[j]>0);
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>100*(r-l+1))break;
                }
                if(sz(ans)>100*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            int len=r-l+1;
            l-=before;
            assert(l>=0);
            for(int j=l-1,g=0;g<(len);j++){
                g++;
                assert(j<sz(res));
                cout<<res[j]<<' ';
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define sz(a) (int)((a).size())
#define fuck() cout<<"--------"<<endl
#define see(x) cout<<#x<<" = "<<x<<endl
#define see2(x,y) cout<<#x<<" = "<<x<<"::"<<#y<<" = "<<y<<endl
const int mod=1000000007;
typedef pair<int,int> pii;
const int inf=1e18;
const int N=1e5+5;
void HyperBeast(){
   int n,l,r;
   cin>>n>>l>>r;
   if(l==r and r==n*(n-1)+1){
    cout<<1;return;
   }
   int before=0;
   vector<pii>ans;
   for(int i=1;i<=n;i++){
        int here=2*(n-i);
        if(before+here>=l){
            for(int x=i;x<=n;x++){
                for(int y=x+1;y<=n;y++){
                    ans.pb({x,y});
                    if(sz(ans)>2*(r-l+1))break;
                }
                if(sz(ans)>2*(r-l+1))break;
            }
            vector<int>res;
            for(auto to:ans){
                res.pb(to.F);
                res.pb(to.S);
            }
            l-=before;
            for(int j=l-1,g=0;g<(r-l+1);j++){
                g++;
                cout<<res[j]<<' ';
                if(res[j]==n and g==r-l){
                    cout<<1;return;
                }
            }
            return;
        }
        else{
            before+=2*(n-i);
        }
   }
}
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;
    while(T--){
        HyperBeast();
        cout<<endl;
    }
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) >= l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = (v == n) ? 1 : v, next = v + 1; bool b = true;
	if (i == l) { goto L; }
	i++;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		if (i == l) { break; }
		i++;
	}
	L : vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) > l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = (v == n) ? 1 : v, next = v + 1; i++; bool b = true;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		if (i == l) { break; }
		i++;
	}
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) > l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = v, next = v + 1; i++; bool b = true;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) { cur++; next = cur + 1; }
		else { next++; }
		if (i == l) { break; }
		i++;
	}
	if (cur == n) { cout << 1 << endl; return; }
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) >= l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = (v == n) ? 1 : v, next = v + 1; bool b = true; i++;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		if (i == l) { break; }
	}
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) > l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = v, next = v + 1; i++; bool b = true;
	while (i < l) {
		b = false;
		if (i + 1 == n) { break; }
		i++; b = true;
		if (next == n) { cur++; next = cur + 1; }
		else { next++; }
		if (i + 1 == n) { break; }
	}
	if (cur == n) { cout << 1 << endl; return; }
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) >= l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = (v == n) ? 1 : v, next = v + 1; i++; bool b = true;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		if (i == l) { break; }
		i++;
	}
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

void find(const ll &n, ll l, ll r) {
	ll i = 0; int v = 1;
	while (true) {
		if (i + 2 * (n - v) >= l) { break; }
		i += 2 * (n - v); v++;
		if (v == n) { break; }
	}
	int cur = (v == n) ? 1 : v, next = v + 1; bool b = true; i++;
	while (i < l) {
		b = false; i++;
		if (i == l) { break; }
		b = true; i++;
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		if (i == l) { break; }
		i++;
	}
	vector<int> res;
	while (i <= r) {
		if (b) { res.push_back(cur); b = false; i++; continue; }
		res.push_back(next);
		if (next == n) {
			if (cur == n - 1) { cur = 1; }
			else { cur++; next = cur + 1; }
		}
		else { next++; }
		i++; b = true;
	}
	for (auto &x : res) { cout << x << ' '; }
	cout << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		ll n, l, r; cin >> n >> l >> r;
		find(n, l, r);
	}
	cin.ignore(2); return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;

	int l=n,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	int cnt=sum(l-1),node=l;

	while(cnt<=R and node<=n)
	{
		for (int i=node+1;i<=n;i++)
		{
			cnt++;
			if(cnt>=L and cnt<=R) cout<<node<<" ";
			cnt++;
			if(cnt>=L and cnt<=R) cout<<i<<" ";

		}
		if(node==n and R==sum(n)+1) return cout<<1<<E,0;
		node++;
	}
     cout<<E;

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> v;
map<int,int> mp;
void fun()
{
	v.push_back(0);
	v.push_back(2);
	int p=2;
	mp[2]=2;
	f(i,3,N)
	{
		int next=p+(i-1)*2;
		mp[next]=i;
		v.push_back(next);
		p=next;
	}

}

int solve()
{
	int n,l,r;
	cin >> n >> l >> r;

	int t=lower_bound(v.begin(),v.end(),l)-v.begin();
	int cnt=v[t-1],node=mp[v[t]],L=l;
	int low;

	vector<int> ans;

	low=(l-cnt+1)/2;
	if((l-cnt)%2==0)
	{
			ans.push_back(node);
			low++;
			l++;
	}

	while(l<=r)
	{
		for( ;low<node;low++)
		{
			ans.push_back(low);
			ans.push_back(node);
			l+=2;
		}
		low=1;
		node++;
	}

	for(int i=0;i<=r-L;i++)
		cout<<ans[i]<<" ";
	cout<<E;
}

int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  fun();
  int t;
  cin >> t;
  while(t--)
  {
  	solve();
  }

}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;

	int l=n,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	int cnt=sum(l-1),node=l,c=20;

	while(cnt<=R and node<=n)
	{
		for (int i=node+1;i<=n;i++)
		{
			ans.push_back(node);
			ans.push_back(i);
			cout<<node<<" "<<i<<" ";
			cnt+=2;
		}
		if(node==n) ans.push_back(1),cnt++;
		node++;
	}

	cnt=sum(l-1);
	for(int i=0;i<=ans.size()-1;i++)
	{
		if(cnt+i+1>=L and cnt+i<=R) cout<<ans[i]<<" ";
	}
	cout<<E;
}

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;

	int l=n,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	int cnt=sum(l-1),node=l;

	while(cnt<=R and node<=n)
	{
		for (int i=node+1;i<=n;i++)
		{
			cnt++;
			if(cnt>=L and cnt<=R) cout<<node<<" ";
			cnt++;
			if(cnt>=L and cnt<=R) cout<<i<<" ";
		}
		if(node==n and cnt>=L and cnt<=R) return cout<<1<<E,0;
		node++;
	}
     cout<<E;

}

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> v;
map<int,int> mp;
void fun()
{
	v.push_back(0);
	v.push_back(2);
	int p=2;
	mp[2]=2;
	f(i,3,N)
	{
		int next=p+(i-1)*2;
		mp[next]=i;
		v.push_back(next);
		p=next;
	}

}

int solve()
{
	int n,l,r;
	cin >> n >> l >> r;

	int t=lower_bound(v.begin(),v.end(),l)-v.begin();
	int cnt=v[t-1],node=mp[v[t]],L=l;
	int low;

	vector<int> ans;

	low=(l-cnt+1)/2;
	if((l-cnt)%2==0)
	{
			ans.push_back(node);
			low++;
			l++;
	}

	while(l<=r)
	{
		for( ;low<node;low++)
		{
			ans.push_back(low);
			ans.push_back(node);
			l+=2;
		}
		low=1;
		node++;
	}

	for(int i=0;i<=r-L;i++)
		cout<<ans[i]<<" ";
	cout<<E;
	return 0;
}

int32_t main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  fun();
  int t;
  cin >> t;
  while(t--)
  {
  	solve();
  }

}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;
	if(L==n*(n-1)+1) return cout<<1<<E,0;

	int l=n-1,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>=L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}

	int node=l,cnt=sum(l-1);

	while(cnt<=R)
	{
		for (int i=node+1;i<=n;i++)
		{
			//cout<<cnt<<" c "<<i<<E;
		 	if(++cnt and cnt>=L and cnt<=R) cout<<node<<" ";
			if(++cnt and cnt>=L and cnt<=R) cout<<i<<" ";

			if(cnt==R) return cout<<E,0;
		}
		if(node==n) return cout<<1<<E,0;
		node++;
		if(cnt==R) break;
	}
}

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;

	int l=n,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	int cnt=sum(l-1),node=l;

	while(cnt<=R and node<=n)
	{
		for (int i=node+1;i<=n;i++)
		{
			cnt++;
			if(cnt<=R) cout<<node<<" ";
			cnt++;
			if(cnt<=R) cout<<i<<" ";
		}
		if(node==n) return cout<<1<<E,0;
		node++;
	}
     cout<<E;

}

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
using namespace std;

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double

const int N=1e5+3;
vector<int> ans;
int n,L,R;

int sum(int k)
{
	return k*(2*n-k-1);
}

int solve(int q)
{
	cin >> n >> L >> R;

	int l=n,low=1,high=n-1,r;
	while(low<=high)
	{
		int mid=(low+high)/2;
		if(sum(mid)>L)
		{
			l=mid;
			high=mid-1;
		}
		else low=mid+1;
	}
	int cnt=sum(l-1),node=l;

	while(cnt<=R and node<=n)
	{
		for (int i=node+1;i<=n;i++)
		{
			cnt++;
			if(cnt>=L and cnt<=R) cout<<node<<" ";
			cnt++;
			if(cnt>=L and cnt<=R) cout<<i<<" ";

		}
		if(node==n and R==sum(n)+1) return cout<<1<<E,0;
		node++;
	}
     cout<<E;
}

int32_t main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  int t;
  cin >> t;
  f(i,1,t+1)
  {
  	solve(i);
  }
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
        {
            l -= 2 * (n - i);
        }
        else
        {
            if(l % 2 == 1)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
        {
            l -= 2 * (n - i);
        }
        else
        {
            if(l % 2 == 1)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << 1 << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
        {
            l -= 2 * (n - i);
        }
        else
        {
            if(l % 2 == 1 && r > 0)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
            l -= 2 * (n - i);
        else
        {
            if(l % 2 == 1 && r > 0)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max((l + i) / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
        {
            l -= 2 * (n - i - 1);
        }
        else
        {
            if(l % 2 == 1 && r > 0)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i - 1) < l)
        {
            l -= 2 * (n - i - 1);
        }
        else
        {
            if(l % 2 == 1 && r > 0)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
            l -= 2 * (n - i);
        else
        {
            if(l % 2 == 1 && r > 0)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = i + l / 2; j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << i << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
            if(r <= 0) break;
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

void solve(ll n, ll l, ll r)
{
    r = r - l + 1;
    for(ll i = 1; i < n; i++)
    {
        if(2 * (n - i) < l)
        {
            l -= 2 * (n - i);
        }
        else
        {
            if(l % 2 == 1)
            {
                cout << i << " ";
                l ++;
                r --;
            }
            for(ll j = max(l / 2 + 1, i + 1); j < n; j++)
            {
                if(r == 0) break;
                cout << j << " ";
                r --;
                if(r == 0) break;
                cout << 1 << " ";
                r --;
                if(r == 0) break;
            }
            l = 1;
            if(r > 0)
            {
                cout << n << " ";
                r --;
            }
        }
    }
    if(r > 0) cout << 1;
    cout << "\n";
}
int main()
{
    turbo

    int t; cin >> t;

    while(t--)
    {
        ll n, l, r; cin >> n >> l >> r;

        solve(n, l, r);

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int abc;
int main()
{
     //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    abc t,n,l,r;

    cin>>t;
    while(t--)
    {
        abc count=0;
        cin>>n>>l>>r;
        for(abc i=1;i<n;i++)
        {
            for(abc j=1;j<n-i+1;j++)
            {
               count++;
               if(count>=l && count<=r)
                    cout<<i<<" ";
               count++;
               if(count>=l && count<=r)
                    cout<<i+j<<" ";
            }

        }
        count++;
        if(count>=l && count<=r)
            cout<<1;

        cout<<"\n";
    }

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int abc;

 int inrange(abc l1,abc r1,abc l2,abc r2)
 {

     return (min(r1,r2)>max(l1,l2));
 }
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
    abc t,n,l,r;

    cin>>t;
    while(t--)
    {
        abc sum=0;
      cin>>n>>l>>r;
    abc temp=1;
      while(1)
      {
          if(inrange(l,r,sum,sum+2*(n-temp)))
          {
              for(abc i=0;i<(n-temp);i++)
              {
                  //cout<<temp<<"\n";
                  sum++;
                  if(sum>=l && sum<=r)
                    cout<<temp<<" ";
                  sum++;
                  if(sum>=l && sum<=r)
                    cout<<temp+i+1<<" ";
              }
            temp++;
          }
          else{
            sum=sum+2*(n-temp);
            temp++;
          }
          if(temp==n)
          {
              sum++;
              if(sum==r)
                cout<<1;
              break;
          }
      }
      cout<<"\n";

    }

    return 0;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long int abc;
int main()
{
     //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    abc t,n,l,r;

    cin>>t;
    while(t--)
    {
        abc sum=0;
        abc count=0;
        cin>>n>>l>>r;
        abc temp=1;

        while((sum+2*(n-temp))<l)
        {
            count=count+2*(n-temp);
            sum=sum+2*(n-temp);
            temp++;
            if(temp==n)
                break;
        }
        int flag=0;
        for(abc i=temp;i<n;i++)
        {
            for(abc j=1;j<n-i+1;j++)
            {
               count++;
               if(count>=l && count<=r)
                    cout<<i<<" ";
               count++;
               if(count>=l && count<=r)
                    cout<<i+j<<" ";

                if(count==r)
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1)
                break;

        }
        count++;
        if(count>=l && count<=r)
            cout<<1;

        cout<<"\n";
    }

    return 0;

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int t = sc.nextInt();
        while (t > 0) {
            long n=sc.nextLong();
            long k=sc.nextLong();
            while(k>0){
                long i=2;
                while(i*i<=n){
                    if(n%i==0){
                        n=n+i;

                        break;
                    }

                    i++;
                    if(i%2==0){
                        i++;
                    }
                }
                if(i>(n/2)){
                    n=n+n;
                }
                k--;
            }
            System.out.println(n);
            t--;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int t = sc.nextInt();
        while (t > 0) {
            long n=sc.nextLong();
            long k=sc.nextLong();
            while(k>0){
                long i=2;
                while(i<=n/2){
                    if(n%i==0){
                        n=n+i;

                        break;
                    }

                    i++;
                }
                if(i>(n/2)){
                    n=n+n;
                }
                k--;
            }
            System.out.println(n);
            t--;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int t = sc.nextInt();
        while (t > 0) {
            long n=sc.nextLong();
            long k=sc.nextLong();
            while(k>0){
                long i=2;
                while(i*i<n){
                    if(n%i==0){
                        n=n+i;

                        break;
                    }

                    i++;
                    if(i%2==0){
                        i++;
                    }
                }
                if(i>(n/2)){
                    n=n+n;
                }
                k--;
            }
            System.out.println(n);
            t--;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int t = sc.nextInt();
        while (t > 0) {
            long n=sc.nextLong();
            long k=sc.nextLong();
            int ans=0;
            if(n%2==0){
                n=n+k*2;
                System.out.println(n);
                ans=1;
            }
            while(k>0 && ans==0){

                n=n+smallestDivisor(n);
                k--;
                if(n%2==0){
                    n=n+2*k;
                    break;
                }

            }
            if(ans==0)
            System.out.println(n);
            t--;
        }

    }
    static long smallestDivisor(long n)
    {
        // if divisible by 2
        if (n % 2 == 0)
            return 2;

        // iterate from 3 to sqrt(n)
        for (int i = 3; i * i <= n; i += 2) {
            if (n % i == 0)
                return i;
        }

        return n;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Scanner sc=new Scanner(System.in);
        int t = sc.nextInt();
        while (t > 0) {
            long n=sc.nextLong();
            long k=sc.nextLong();
            while(k>0){
                long i=2;
                while(i*i<=n){
                    if(n%i==0){
                        n=n+i;

                        break;
                    }

                    i=i+2;
                }
                if(i>(n/2)){
                    n=n+n;
                }
                k--;
            }
            System.out.println(n);
            t--;
        }

    }
}


import java.util.*;
import java.io.*;
public class Main
{
    static PrintWriter out;

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

    public static int no(int n)
    {
        if(n>=1 && n<=9)
        {
            return 1 ;
        }

        return no(n/10) + 1 ;
    }

    public static long help(long n)
    {
        for(long i = 2; i <= n ; i++)
        {
            if(n% i == 0) return i ;
        }

        return 2 ;
    }

     public static long sol(long n , long k )
     {
        if(k == 1)
        {
          return  help(n) + n ;
        }

        long ans = sol(help(n) + n , k-1 ) ;

        return ans  ;

     }

    public static void main(String[] args)
    {
       FastReader scn = new FastReader();

      int t = scn.nextInt() ;

      for( int m = 1; m<=  t; m++){
       long n,k;
       n = scn.nextLong() ;
       k = scn.nextLong() ;

       out.println(sol(n,k)) ;
      }

        out.flush() ;

    }
}


import java.util.*;
import java.io.*;
public class Main
{
    static PrintWriter out;

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

    public static int no(int n)
    {
        if(n>=1 && n<=9)
        {
            return 1 ;
        }

        return no(n/10) + 1 ;
    }

    public static long help(long n)
    {
        for(long i = 2; i <= n ; i++)
        {
            if(n% i == 0) return i ;
        }

    }

     public static long sol(long n , long k )
     {
        if(k == 1)
        {
          return  help(n) + n ;
        }

        long ans = sol(help(n) + n , k-1 ) ;

        return ans  ;

     }

    public static void main(String[] args)
    {
       FastReader scn = new FastReader();

      int t = scn.nextInt() ;

      for( int m = 1; m<=  t; m++){
       long n,k;
       n = scn.nextLong() ;
       k = scn.nextLong() ;

       out.println(sol(n,k)) ;
      }

        out.flush() ;

    }
}


import java.util.*;
import java.io.*;
public class Main
{
    static PrintWriter out;

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
			out=new PrintWriter(System.out);
		}
		String next(){
			while(st==null || !st.hasMoreElements()){
				try{
					st= new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(next());
		}
		long nextLong(){
			return Long.parseLong(next());
		}
		double nextDouble(){
			return Double.parseDouble(next());
		}
		String nextLine(){
			String str = "";
			try{
				str=br.readLine();
			}
			catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}

    public static int no(int n)
    {
        if(n>=1 && n<=9)
        {
            return 1 ;
        }

        return no(n/10) + 1 ;
    }

    public static long help(long n)
    {
        for(long i = 3; i <= n ; i++)
        {
            if(n% i == 0) return i ;
        }

        return 2 ;
    }

     public static long sol(long n , long k )
     {
        if(k == 1)
        {
          return  help(n) + n ;
        }

        long ans = sol(help(n) + n , k-1 ) ;

        return ans  ;

     }

    public static void main(String[] args)
    {
       FastReader scn = new FastReader();

      int t = scn.nextInt() ;

      for( int m = 1; m<=  t; m++){
       long n,k;
       n = scn.nextLong() ;
       k = scn.nextLong() ;

        StringBuilder sb = new StringBuilder() ;

       if(n% 2 == 0)
       {
         sb.append(n+2*k) ;
       }

       else{

           if( k == 1)
           {
               sb.append(help(n) + n ) ;
           }

           else{

               long ans = help(n) + n ;
               sb.append(ans + 2*(k-1) ) ;

           }

       }

       out.println(sb) ;
      }

        out.flush() ;

    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Cf131 implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception
    {
        new Thread(null, new Cf131(),"Main",1<<27).start();
    }

    static class Pair{
        int nod;
        int ucn;

        Pair(int nod,int ucn){
            this.nod=nod;
            this.ucn=ucn;

        }

    public static Comparator<Pair> wc = new Comparator<Pair>(){
        public int compare(Pair e1,Pair e2){

            //reverse order
            if (e1.ucn < e2.ucn)
                return 1;  // 1 for swaping.
            else if (e1.ucn > e2.ucn)
                return -1;
            else{
                // if(e1.siz>e2.siz)
                //     return 1;
                // else
                //     return -1;
                return 0;
            }
        }
    };
    }

    public static long gcd(long a,long b){
        if(b==0)return a;
        else return gcd(b,a%b);
    }

    ////recursive BFS
    public static int bfsr(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,int[] pre){
        b[s]=true;
        int p = 0;
        int t = a[s].size();
        for(int i=0;i<t;i++){
            int x = a[s].get(i);
            if(!b[x]){
                dist[x] = dist[s] + 1;
                p+= (bfsr(x,a,dist,b,pre)+1);
            }
        }
        pre[s] = p;
        return p;
    }

//// iterative BFS
    public static int bfs(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,PrintWriter w){
        b[s]=true;
        int siz = 0;

        Queue<Integer> q = new LinkedList<>();
        q.add(s);
        while(q.size()!=0){
            int i=q.poll();
        //    w.println(" #"+i+"# ");
            Iterator<Integer> it =a[i].listIterator();
            int z=0;
            while(it.hasNext()){
                z=it.next();
               // w.println("#"+i+" "+z);
                if(!b[z]){
                //    w.println("* "+z+" *");
                    b[z]=true;
                    dist[z] = dist[i] + 1;
                 //   w.print("*");
                   // w.println(i+" "+z);
                    siz++;
                //    x.add(z);
                //    w.println("@ "+x.get(x.size()-1)+" @");
                    q.add(z);
                }
            }

        }
        return siz;
    }

//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int defaultValue=0;
        int[] a = new int[15000003];
        for(int i=2;i<a.length;i++){
            boolean f = true;
            for(int j=2;j<=(int)(double)Math.sqrt(i);j++){
                if(i%j==0){a[i]=j;f = false;break;}

            }
            if(f)a[i] = i;
        }

        int t = sc.nextInt();
        while(t-->0){

            int n = sc.nextInt();
            int k = sc.nextInt();
            int ans = n;
            while(k-->0){
                ans += a[ans];
            }
            w.println(ans);

        }
        w.flush();
        w.close();

    }

}