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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

int n, m;
vector <int> graph[500001];

vector <int> stk;
int par[500001];
int depth[500001];
void pDFS(int v, int p, int d)
{
	stk.push_back(v);

	for (int nv : graph[v])
	{
		if (par[nv] == v && depth[nv] + 1 == d)
		{
			pDFS(nv, v, d - 1);
			break;
		}
	}
}

bool isPath;
void PATH(int v, int d1, int d2, int c1, int c2)
{
	isPath = 1;
	cout << "PATH\n";
	cout << d1 + d2 + 1 << '\n';

	stk.clear();
	pDFS(c1, v, d1);

	reverse(stk.begin(), stk.end());
	for (int cv : stk) cout << cv << ' ';
	cout << v << ' ';

	stk.clear();
	pDFS(c2, v, d2);

	for (int cv : stk) cout << cv << ' ';
	cout << '\n';
}

int cache[500001];
void DFS(int v)
{
	cache[v] = 1;
	depth[v] = 1;

	int d1 = 0, d2 = 0;
	int c1 = -1, c2 = -1;

	for (int nv : graph[v])
	{
		if (cache[nv]) continue;

		DFS(nv);
		par[nv] = v;

		if (depth[nv] > d2)
		{
			d2 = depth[nv];
			c2 = nv;
		}

		if (d1 < d2)
		{
			swap(d1, d2);
			swap(c1, c2);
		}

		depth[v] = max(depth[v], depth[nv] + 1);
	}

	if (!isPath && d1 + d2 + 1 >= (n + 1) / 2)
	{
		PATH(v, d1, d2, c1, c2);
	}
}

bool isAns[500001];

int DFS_cnt = 1;
int DFS_num[500001];
int DFS_min[500001];
int child[500001];

void atDFS(int v, int p)
{
	DFS_num[v] = DFS_min[v] = DFS_cnt++;
	for (int nv : graph[v])
	{
		if (nv == p) continue;

		if (DFS_num[nv])
		{
			DFS_min[v] = min(DFS_min[v], DFS_num[nv]);
		}
		else
		{
			child[v]++;
			atDFS(nv, v);
			DFS_min[v] = min(DFS_min[v], DFS_min[nv]);

			if (DFS_min[nv] >= DFS_num[v])
			{
				isAns[v] = 1;
			}
		}
	}
}

vector <vector<int> > cc;
void PAIRING(int v, vector <int>& vec)
{
	if (isAns[v])
	{
		for (int nv : graph[v])
		{
			if (par[nv] != v) continue;
			vector <int> new_vec;
			PAIRING(nv, new_vec);

			if (!new_vec.empty()) cc.push_back(new_vec);
		}
	}
	else
	{
		vec.push_back(v);
		for (int nv : graph[v])
		{
			if (par[nv] != v) continue;
			PAIRING(nv, vec);
		}
	}
}

bool cmp(vector <int>& v1, vector<int>& v2)
{
	return v1.size() > v2.size();
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int t; cin >> t;
	while (t--)
	{
		cin >> n >> m;
		for (int i = 1; i <= n; i++)
		{
			graph[i].clear();
			cache[i] = 0;

			DFS_num[i] = 0, DFS_min[i] = 0;
			child[i] = 0;
		}

		DFS_cnt = 0;
		isPath = 0;
		cc.clear();

		for (int i = 0; i < m; i++)
		{
			int u, v; cin >> u >> v;
			graph[u].push_back(v);
			graph[v].push_back(u);
		}

		DFS(1);

		if (isPath) continue;

		atDFS(1, 0);

		if (isAns[1] && child[1] < 2) isAns[1] = 0;

		vector <int> tmp;
		cout << "PAIRING\n";
		PAIRING(1, tmp);

		if (!tmp.empty()) cc.push_back(tmp);

		sort(cc.begin(), cc.end(), cmp);

		vector<pii> ans;

		for (int i = 0; i < cc.size() && ans.size() * 2 < (n + 1) / 2; i++)
		{
			for (int j = i + 1; j < cc.size() && !cc[i].empty() && ans.size() * 2 < (n + 1) / 2; j++)
			{
				while (!cc[i].empty() && !cc[j].empty() && ans.size() * 2 < (n + 1) / 2)
				{
					ans.push_back({ cc[i].back(), cc[j].back() });
					cc[i].pop_back();
					cc[j].pop_back();
				}
			}
		}

		if (ans.size() * 2 < (n + 1) / 2) return -1;

		cout << ans.size() << '\n';
		for (pii it : ans)
		{
			cout << it.first << ' ' << it.second << '\n';
		}
	}
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f(i,p,n) for(ll i=p;i<n;i++)
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

ll exp(ll a,ll b,ll m);

ll pr[1000005];
bool vis[1000005];
ll de[1000005];
vector<ll> tr[1000005];

void dfs(ll a, ll par)
{
	if(vis[a]==1) return;

	vis[a] = 1;
	if(par!=-1) de[a] = de[par] + 1;

	pr[a] = par;

	for(auto v: tr[a])
	{
		dfs(v,a);
	}
}

int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif

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

    	f(i,1,n+1)
    	{
    		tr[i].clear();
    		de[i] = 0;
    		vis[i] = 0;
    		pr[i] = 0;
    	}
    	ll x,y;
    	f(i,0,m)
    	{
    		cin>>x>>y;
    		tr[x].pb(y);
    		tr[y].pb(x);
    	}

    	dfs(1,-1);

    	ll ce = n - n/2;
    	bool ok = 0;
    	f(i,1,n+1)
    	{
    		if(de[i]>=ce)
    		{
    			ll ind = i;
    			cout<<"PATH"<<endl;
    			cout<<de[i]<<endl;
    			while(ind!=-1)
    			{
    				cout<<ind<<" ";
    				ind = pr[ind];
    			}
    			cout<<endl;
    			ok = 1;
    			break;
    		}
    	}

    	if(ok) continue;

    	vector<ll> sb[n];

    	f(i,1,n+1) sb[de[i]].pb(i);

    	vector<pl> ans;

    	f(i,1,n+1)
    	{
    		ll sz = sb[i].size();
    		for(ll j = 0; j+1<sz;j+=2)
    		{
    			ans.pb(mp(sb[i][j],sb[i][j+1]));
    		}
    	}

    	cout<<"PAIRING"<<endl;
    	cout<<ans.size()<<" ";

    	for(auto v: ans)
    	{
    		cout<<v.ff<<" "<<v.ss<<endl;
    	}
    }

return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f(i,p,n) for(ll i=p;i<n;i++)
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

ll exp(ll a,ll b,ll m);

ll pr[1000005];
bool vis[1000005];
ll de[1000005];
vector<ll> tr[1000005];

void dfs(ll a, ll par)
{
	if(vis[a]==1) return;

	vis[a] = 1;
	if(par!=-1) de[a] = de[par] + 1;

	pr[a] = par;

	for(auto v: tr[a])
	{
		dfs(v,a);
	}
}

int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif

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

    	f(i,1,n+1)
    	{
    		tr[i].clear();
    		de[i] = 0;
    		vis[i] = 0;
    		pr[i] = 0;
    	}
    	ll x,y;
    	f(i,0,m)
    	{
    		cin>>x>>y;
    		tr[x].pb(y);
    		tr[y].pb(x);
    	}

    	dfs(1,-1);

    	ll ce = n - n/2;
    	bool ok = 0;
    	f(i,1,n+1)
    	{
    		if(de[i]+1>=ce)
    		{
    			ll ind = i;
    			cout<<"PATH"<<endl;
    			cout<<de[i]+1<<endl;
    			while(ind!=-1)
    			{
    				cout<<ind<<" ";
    				ind = pr[ind];
    			}
    			cout<<endl;
    			ok = 1;
    			break;
    		}
    	}

    	if(ok) continue;

    	vector<ll> sb[n+1];

    	f(i,1,n+1) sb[de[i]].pb(i);

    	vector<pl> ans;

    	f(i,1,n+1)
    	{
    		ll sz = sb[i].size();
    		for(ll j = 0; j+1<sz;j+=2)
    		{
    			ans.pb(mp(sb[i][j],sb[i][j+1]));
    		}
    	}

    	cout<<"PAIRING"<<endl;
    	cout<<ans.size()<<endl;

    	for(auto v: ans)
    	{
    		cout<<v.ff<<" "<<v.ss<<endl;
    	}
    }

return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f(i,p,n) for(ll i=p;i<n;i++)
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

ll exp(ll a,ll b,ll m);

ll pr[1000005];
bool vis[1000005];
ll de[1000005];
vector<ll> tr[1000005];

void dfs(ll a, ll par)
{
	if(vis[a]==1) return;

	vis[a] = 1;
	if(par!=-1) de[a] = de[par] + 1;

	pr[a] = par;

	for(auto v: tr[a])
	{
		dfs(v,a);
	}
}

int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif

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

    	f(i,1,n+1)
    	{
    		tr[i].clear();
    		de[i] = 0;
    		vis[i] = 0;
    		pr[i] = 0;
    	}
    	ll x,y;
    	f(i,0,m)
    	{
    		cin>>x>>y;
    		tr[x].pb(y);
    		tr[y].pb(x);
    	}

    	dfs(1,-1);

    	ll ce = n - n/2;
    	bool ok = 0;
    	f(i,1,n+1)
    	{
    		if(de[i]+1>=ce)
    		{
    			ll ind = i;
    			cout<<"PATH"<<endl;
    			cout<<de[i]+1<<endl;
    			while(ind!=-1)
    			{
    				cout<<ind<<" ";
    				ind = pr[ind];
    			}
    			cout<<endl;
    			ok = 1;
    			break;
    		}
    	}

    	if(ok) continue;

    	vector<ll> sb[n];

    	f(i,1,n+1) sb[de[i]].pb(i);

    	vector<pl> ans;

    	f(i,1,n+1)
    	{
    		ll sz = sb[i].size();
    		for(ll j = 0; j+1<sz;j+=2)
    		{
    			ans.pb(mp(sb[i][j],sb[i][j+1]));
    		}
    	}

    	cout<<"PAIRING"<<endl;
    	cout<<ans.size()<<" ";

    	for(auto v: ans)
    	{
    		cout<<v.ff<<" "<<v.ss<<endl;
    	}
    }

return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define f(i,p,n) for(ll i=p;i<n;i++)
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
typedef pair<ll,ll> pl;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

ll exp(ll a,ll b,ll m);

ll pr[1000005];
bool vis[1000005];
ll de[1000005];
vector<ll> tr[1000005];

void dfs(ll a, ll par)
{
	if(vis[a]==1) return;

	vis[a] = 1;
	if(par!=-1) de[a] = de[par] + 1;

	pr[a] = par;

	for(auto v: tr[a])
	{
		dfs(v,a);
	}
}

int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif

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

    	f(i,1,n+1)
    	{
    		tr[i].clear();
    		de[i] = 0;
    		vis[i] = 0;
    		pr[i] = 0;
    	}
    	ll x,y;
    	f(i,0,m)
    	{
    		cin>>x>>y;
    		tr[x].pb(y);
    		tr[y].pb(x);
    	}

    	dfs(1,-1);

    	ll ce = n - n/2;
    	bool ok = 0;
    	f(i,1,n+1)
    	{
    		if(de[i]+1>=ce)
    		{
    			ll ind = i;
    			cout<<"PATH"<<endl;
    			cout<<de[i]+1<<endl;
    			while(ind!=-1)
    			{
    				cout<<ind<<" ";
    				ind = pr[ind];
    			}
    			cout<<endl;
    			ok = 1;
    			break;
    		}
    	}

    	if(ok) continue;

    	vector<ll> sb[n];

    	f(i,1,n+1) sb[de[i]].pb(i);

    	vector<pl> ans;

    	f(i,1,n+1)
    	{
    		ll sz = sb[i].size();
    		for(ll j = 0; j+1<sz;j+=2)
    		{
    			ans.pb(mp(sb[i][j],sb[i][j+1]));
    		}
    	}

    	cout<<"PAIRING"<<endl;
    	cout<<ans.size()<<endl;

    	for(auto v: ans)
    	{
    		cout<<v.ff<<" "<<v.ss<<endl;
    	}
    }

return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 500005
#define mod 1000000007
#define INF INT_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(N);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i < 1e8; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j < 1e8; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll t, n, m;
vector<vector<ll>> adj(N), l(N);
vector<ll> visited(N), dep(N), par(N);
ll vert;

void dfs(ll u, ll d=1, ll p=0)
{
    visited[u] = 1;
    dep[u]=d;
    l[d].pb(u);
    par[u]=p;
    if (dep[u]>=(n/2+n%2))
        vert=u;
    for (auto x:adj[u])
    {
        if (!visited[x])
        {
            dfs(x, d+1, u);
        }
    }
}

void input_adj(ll n)
{
    for (long long int i = 0; i < n - 1; i++)
    {
        ll u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin>>t;
    while (t--)
    {
        cin>>n>>m;
        input_adj(m+1);
        dfs(1);
        if (vert)
        {
            cout<<"PATH\n";
            v<ll> ans;
            while (vert!=0)
                ans.pb(vert), vert = par[vert];
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x<<" ";
            cout<<"\n";
        }
        else
        {
            cout<<"PAIRING\n";
            v<pair<ll, ll>> ans;
            for (ll j=1;j<=n;j++)
            {
                for (ll i=0;i<l[j].size() && i+1<l[j].size();i+=2)
                    ans.pb(mp(l[j][i], l[j][i+1]));
            }
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x.fi<<" "<<x.se<<"\n";
        }
        for (ll i=0;i<=n;i++)
            adj[i].clear(), visited[i]=0, dep[i]=0, par[i]=0, l[i].clear();
        vert=0;
    }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 500005
#define mod 1000000007
#define INF INT_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(N);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i < 1e8; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j < 1e8; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll t, n, m;
vector<vector<ll>> adj(N), l(N);
vector<ll> visited(N), dep(N), par(N);
ll vert;

void dfs(ll u, ll d=1, ll p=0)
{
    visited[u] = 1;
    dep[u]=d;
    l[d].pb(u);
    par[u]=p;
    if (dep[u]>=(n/2+n%2))
        vert=u;
    for (ll i = 0; i < adj[u].size(); i++)
    {
        if (!visited[adj[u][i]])
        {
            dfs(adj[u][i], d+1, u);
        }
    }
}

void input_adj(long long int n)
{
    for (long long int i = 0; i < n - 1; i++)
    {
        long long int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin>>t;
    while (t--)
    {
        cin>>n>>m;
        input_adj(m+1);
        dfs(1);
        if (vert)
        {
            cout<<"PATH\n";
            v<ll> ans;
            ans.pb(vert);
            vert= par[vert];
            while (vert!=0)
                ans.pb(vert), vert = par[vert];
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x<<" ";
            cout<<"\n";
        }
        else
        {
            cout<<"PAIRING\n";
            v<pair<ll, ll>> ans;
            for (auto x:l)
            {
                for (ll i=0;i<x.size() && i+1<x.size();i+=2)
                    ans.pb(mp(x[i], x[i+1]));
            }
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x.fi<<" "<<x.se<<"\n";
        }
        for (ll i=0;i<=n;i++)
            adj[i].clear(), visited[i]=0, dep[i]=0, par[i]=0, l[i].clear();
        vert=0;
    }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 500005
#define mod 1000000007
#define INF INT_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(N);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i < 1e8; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j < 1e8; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll t, n, m;
vector<vector<ll>> adj(N), l(N);
vector<ll> visited(N), dep(N), par(N);
ll vert;

void dfs(ll u, ll d=1, ll p=0)
{
    visited[u] = 1;
    dep[u]=d;
    l[d].pb(u);
    par[u]=p;
    if (dep[u]>=(n/2+n%2))
        vert=u;
    for (ll i = 0; i < adj[u].size(); i++)
    {
        if (!visited[adj[u][i]])
        {
            dfs(adj[u][i], d+1, u);
        }
    }
}

void input_adj(long long int n)
{
    for (long long int i = 0; i < n - 1; i++)
    {
        long long int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin>>t;
    while (t--)
    {
        cin>>n>>m;
        input_adj(m+1);
        dfs(1);
        if (vert)
        {
            cout<<"PATH\n";
            v<ll> ans;
            ans.pb(vert);
            vert= par[vert];
            while (vert!=0 && ans.size()<(n/2+n%2))
                ans.pb(vert), vert = par[vert];
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x<<" ";
            cout<<"\n";
        }
        else
        {
            cout<<"PAIRING\n";
            v<pair<ll, ll>> ans;
            for (auto x:l)
            {
                if (ans.size()>(n/2+n%2))
                    break;
                for (ll i=0;i<x.size() && i+1<x.size();i+=2)
                    ans.pb(mp(x[i], x[i+1]));
            }
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x.fi<<" "<<x.se<<"\n";
        }
        for (ll i=0;i<=n;i++)
            adj[i].clear(), visited[i]=0, dep[i]=0, par[i]=0, l[i].clear();
        vert=0;
    }
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 500005
#define mod 1000000007
#define INF INT_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

// v<ll> fact(N);
// v<ll> prime_check(N);
// v<ll> primes;

// long long powmod(long long x, long long y, long long m)
// {
//     long long res = 1LL;
//     while (y)
//     {
//         if (y & 1)
//             res = (res * x) % m;
//         x = (x * x) % m;
//         y /= 2;
//     }
//     return res;
// }

// void init_fact()
// {
//     fact[0] = 1;
//     for (ll i = 1; i < N; i++)
//     {
//         fact[i] = (fact[i - 1] * i) % mod;
//     }
// }

// ll C(ll n, ll r)
// {
//     if (n < r)
//         return 0;
//     ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
//     temp *= powmod(fact[n - r], mod - 2, mod);
//     temp %= mod;
//     return temp;
// }

// void Sieve()
// {
//     for (ll i = 2; i < 1e8; i++)
//     {
//         if (prime_check[i])
//             continue;
//         primes.pb(i);
//         for (ll j = 2 * i; j < 1e8; j += i)
//             prime_check[j] = i;
//     }
// }
// ll phi(ll n)
// {
//     ll i, res = n;
//     for (i = 2; i * i <= n; i++)
//         if (n % i == 0)
//         {
//             while (n % i == 0)
//                 n /= i;
//             res -= res / i;
//         }
//     if (n > 1)
//         res -= res / n;
//     return res;
// }

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll t, n, m;
vector<vector<ll>> adj(N), l(N);
vector<ll> visited(N), dep(N), par(N);
ll vert;

void dfs(ll u, ll d=1, ll p=0)
{
    visited[u] = 1;
    dep[u]=d;
    l[d].pb(u);
    par[u]=p;
    if (dep[u]>=(n/2+n%2))
        vert=u;
    for (ll i = 0; i < adj[u].size(); i++)
    {
        if (!visited[adj[u][i]])
        {
            dfs(adj[u][i], d+1, u);
        }
    }
}

void input_adj(long long int n)
{
    for (long long int i = 0; i < n - 1; i++)
    {
        long long int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    cin>>t;
    while (t--)
    {
        cin>>n>>m;
        input_adj(m+1);
        dfs(1);
        if (vert)
        {
            cout<<"PATH\n";
            v<ll> ans;
            ans.pb(vert);
            vert= par[vert];
            while (vert!=0)
                ans.pb(vert), vert = par[vert];
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x<<" ";
            cout<<"\n";
        }
        else
        {
            cout<<"PAIRING\n";
            v<pair<ll, ll>> ans;
            for (auto x:l)
            {
                for (ll i=0;i<x.size() && i+1<x.size();i+=2)
                    ans.pb(mp(x[i], x[i+1]));
            }
            cout<<ans.size()<<"\n";
            for (auto x:ans)
                cout<<x.fi<<" "<<x.se<<"\n";
        }
        for (ll i=0;i<=n;i++)
            adj[i].clear(), visited[i]=0, dep[i]=0, par[i]=0, l[i].clear();
        vert=0;
    }
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(min(p1.y, p2.y)==0) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i<<" ";
       cout<<endl;
   }
   cout.flush();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

/*
 1
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i<<" ";
       cout<<endl;
   }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        degree[i]=tree[i].size();
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(min(p1.y, p2.y)==0) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           degree[parent[p1.y]]--;
           //setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           degree[parent[p2.y]]--;
           //setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
       if(parent[p1.y]!=-1 && degree[parent[p1.y]]==1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1 && degree[parent[p2.y]]==1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i<<" ";
       cout<<endl;
   }
   cout.flush();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

/*
 1
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        degree[i]=tree[i].size();
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(min(p1.y, p2.y)==0) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           degree[parent[p1.y]]--;
           //setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           degree[parent[p2.y]]--;
           //setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
       if(parent[p1.y]!=-1 && degree[parent[p1.y]]==1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1 && degree[parent[p2.y]]==1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }

       depth[kek]=0;
       for(int i=0;i<n;i++) was[i]=false;
       dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       //assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i+1<<" ";
       cout<<endl;
   }
   cout.flush();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

/*
 1
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(parent[p1.y]==p2.y||parent[p2.y]==p1.y) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i<<" ";
       cout<<endl;
   }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        degree[i]=tree[i].size();
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(min(p1.y, p2.y)==0) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           degree[parent[p1.y]]--;
           //setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           degree[parent[p2.y]]--;
           //setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
       if(parent[p1.y]!=-1 && degree[parent[p1.y]]==1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1 && degree[parent[p2.y]]==1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }

       depth[kek]=0;
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       //assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i+1<<" ";
       cout<<endl;
   }
   cout.flush();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

/*
 1
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        degree[i]=tree[i].size();
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       if(min(p1.y, p2.y)==0) break;
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           degree[parent[p1.y]]--;
           //setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           degree[parent[p2.y]]--;
           //setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
       if(parent[p1.y]!=-1 && degree[parent[p1.y]]==1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1 && degree[parent[p2.y]]==1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       //assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i+1<<" ";
       cout<<endl;
   }
   cout.flush();
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

/*
 1
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
 */
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>
#define lupa cout<<"ok\n"; cout.flush();
#define x first
#define y second
vector<vector<int>> vert;
vector<vector<int>> tree;
vector<int> depth;
vector<int> parent;
vector<bool> was;
vector<int> degree;
void dfs(int v, int p){
    was[v]=true;
    parent[v]=p;
    for(int son:vert[v]){
        if(was[son]) continue;
        depth[son]=depth[v]+1;
        tree[son].pb(v);
        tree[v].pb(son);
        dfs(son, v);
    }

}
void solve() {
    int n,m;
    cin>>n>>m;
    vert.clear();
    tree.clear();
    was.clear();
    parent.clear();
    depth.clear();
    degree.clear();
    vert.assign(n, vector<int>(0));
    tree.assign(n, vector<int>(0));
    was.assign(n, false);
    parent.assign(n, -1);
    depth.assign(n, 0);
    degree.assign(n, 0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        --u,--v;
        vert[u].pb(v);
        vert[v].pb(u);
    }
    dfs(0,-1);
    vector<int> order(n);
    set<pii> setik;
    for(int i=0;i<n;i++){
        if(tree[i].size()==1) {
            setik.insert({-depth[i], i});
        }
    }
    vector<pii> shit;
   while(setik.size()>1){
       pii p1=*setik.begin();
       setik.erase(setik.begin());
       pii p2=*setik.begin();
       setik.erase(setik.begin());
       shit.pb({p1.y,p2.y});
       if(parent[p1.y]!=-1){
           setik.insert({-depth[parent[p1.y]],parent[p1.y]});
       }
       if(parent[p2.y]!=-1){
           setik.insert({-depth[parent[p2.y]],parent[p2.y]});
       }
   }
   if(shit.size()*2>=(n+1)/2){
       cout<<"PAIRING\n";
       cout<<shit.size()<<endl;
       for(pii &p:shit) cout<<p.x+1<<" "<<p.y+1<<endl;
   }
   else{
       cout<<"PATH\n";
       int kek=0;
       int mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek=i;
               mx=depth[i];
           }
       }
        dfs(kek, -1);

       int kek2=0;
       mx=0;
       for(int i=0;i<n;i++) {
           if(depth[i]>mx){
               kek2=i;
               mx=depth[i];
           }
       }
       vector<int> ans;
       while(kek2!=kek){
           ans.pb(kek2);
           kek2=parent[kek2];
       }
       ans.pb(kek);
       assert(ans.size()>=(n+1)/2);
       cout<<ans.size()<<endl;
       for(int i:ans) cout<<i<<" ";
       cout<<endl;
   }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(1);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int N = 1e6;
set<int>g[N];
int n,m;
int main() {
    int t;
    scanf("%d", &t);
    while (t --) {
        scanf("%d %d", &n, &m);
        set<int> f;
        for (int i =1; i <= n; i ++) f.insert(i);
        for (int i = 1; i <= m; i ++) {
            int x ,y;
            scanf("%d %d", &x, &y);
            g[x].insert(y);
            g[y].insert(x);
        }

        int k = ((n + 1) / 2 + 1) / 2;
        //
        vector<pair<int, int> > ans;
        for (int i  =1; i <= n && k; i ++)
        if (f.find(i) != f.end()){
            f.erase(i);
            int last = 0;
            while (1) {
                auto u = f.upper_bound(last);
                if (u == f.end()) break;
                if (g[i].find(*u) == g[i].end()) {
                    //printf("%d %d\n", *u, i);
                    ans.push_back({*u, i});
                    f.erase(u);
                    k --;
                    break;
                }
                last = *u;
            }
        }
        if (!k) {
            puts("PAIRING");printf("%d\n", ans.size());
            for (auto u:ans)
                printf("%d %d\n", u.first, u.second);
            for (int i =1; i <= n; i ++)
                g[i].clear();
            continue;
        }
        puts("PATH");

        printf("%d\n",k); k = ((n + 1) / 2 + 1) / 2;
        int x = 1;
        printf("%d", x);
        set<int> w;
        while (--k) {
            w.insert(x);
            for (auto u :g[x])
                if (w.find(u) == w.end()){
                    printf(" %d", u);
                    x = u;
                    break;
                }
        }
        printf("\n");
        for (int i =1; i <= n; i ++)
            g[i].clear();
    }
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int N = 1e6;
set<int>g[N];
int n,m;
int main() {
    int t;
    scanf("%d", &t);
    while (t --) {
        scanf("%d %d", &n, &m);
        set<int> f;
        for (int i =1; i <= n; i ++) f.insert(i);
        for (int i = 1; i <= m; i ++) {
            int x ,y;
            scanf("%d %d", &x, &y);
            g[x].insert(y);
            g[y].insert(x);
        }

        int k = ((n + 1) / 2 + 1) / 2;
        //
        vector<pair<int, int> > ans;
        for (int i  =1; i <= n && k; i ++)
        if (f.find(i) != f.end()){
            f.erase(i);
            int last = 0;
            while (1) {
                auto u = f.upper_bound(last);
                if (u == f.end()) break;
                if (g[i].find(*u) == g[i].end()) {
                    //printf("%d %d\n", *u, i);
                    ans.push_back({*u, i});
                    f.erase(u);
                    k --;
                    break;
                }
                last = *u;
            }
        }
        if (!k) {
            puts("PAIRING");printf("%d\n", ans.size());
            for (auto u:ans)
                printf("%d %d\n", u.first, u.second);
            for (int i =1; i <= n; i ++)
                g[i].clear();
            continue;
        }
        puts("PATH");
        k = (n + 1) / 2;
        printf("%d\n",k);
        int x = 1;
        printf("%d", x);
        set<int> w;
        while (--k) {
            w.insert(x);
            for (auto u :g[x])
                if (w.find(u) == w.end()){
                    printf(" %d", u);
                    x = u;
                    break;
                }
        }
        printf("\n");
        for (int i =1; i <= n; i ++)
            g[i].clear();
    }
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
const int N = 1e6;
vector<int>g[N];
int n,m;
int lst[N];
bool bz[N];
vector<pair<int, int> > ans;
vector<int> d;
bool dfs(int x) {
    bz[x] = 1;
    d.push_back(x);
    if (lst[d.size()]) {
        ans.push_back({x, lst[d.size()]});
        lst[d.size()] = 0;
    } else lst[d.size()] = x;
    if (d.size() == (n + 1) / 2) {
        puts("PATH");
        printf("%d\n", d.size());
        for (int i = 0; i < d.size() ;i ++)
            printf("%d%c", d[i], " \n"[i == (int)d.size() - 1]);
        return 1;
    }
    for (auto u:g[x])
        if (!bz[u]) {
            if (dfs(u)) return 1;
        }
    d.pop_back();
    return 0;
}
int main() {
    int t;
    scanf("%d", &t);
    while (t --) {
        scanf("%d %d", &n, &m);
        ans.clear();
        for (int i = 1; i <= m; i ++) {
            int x ,y;
            scanf("%d %d", &x, &y);
            g[x].push_back(y);
            g[y].push_back(x);
            bz[i] = 0;
            lst[i] = 0;
        }
        d.clear();
        if (!dfs(1)) {
            puts("PAIRING");
            printf("%d\n", ans.size());
            for (auto u: ans)
                printf("%d %d\n", u.first, u.second);
        }

        for (int i =1; i <= n; i ++)
            g[i].clear();
    }
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int N = 1e6;
set<int>g[N];
int n,m;
int main() {
    int t;
    scanf("%d", &t);
    while (t --) {
        scanf("%d %d", &n, &m);
        set<int> f;
        for (int i =1; i <= n; i ++) f.insert(i);
        for (int i = 1; i <= m; i ++) {
            int x ,y;
            scanf("%d %d", &x, &y);
            g[x].insert(y);
            g[y].insert(x);
        }

        puts("PAIRING");
        int k = ((n + 1) / 2 + 1) / 2;
        printf("%d\n", k);
        for (int i  =1; i <= n && k; i ++)
        if (f.find(i) != f.end()){
            f.erase(i);
            int last = 0;
            while (1) {
                auto u = f.upper_bound(last);
                if (u == f.end()) break;
                if (g[i].find(*u) == g[i].end()) {
                    printf("%d %d\n", *u, i);
                    f.erase(u);
                    k --;
                    break;
                }
                last = *u;
            }
        }

        for (int i =1; i <= n; i ++)
            g[i].clear();
    }
    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    ii mark = {-1,0};
    for( auto v : t[u] ){
        if( v != p ){
            mark = max( mark , { subt[v] , v } );
        }
    }
    if( n - lv[u] - 1 < ( n + 1 ) / 2 )
    mark = {0,0};
    for( auto v : t[u] ){
        if( v != p && v != mark.s ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark.s ) return u;
    return find_(mark.s,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        int sum = 0;
        for(int i=1; i<=cnt; i++)
            sum += v[i].size();

        vector<int> vx;
        for(int i=1; i<=cnt; i++){
            for(int j=0; j<min((int)v[i].size(),sum-(int)v[i].size()); j++)
                vx.pb(v[i][j]);
        }
        if( vx.size() % 2 ) vx.pop_back();

        vector<ii> ans;
        for(int i=0; i<vx.size()/2; i++)
            ans.pb({vx[i],vx[i+vx.size()/2]});

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( ( n - lv[u] - subt[u] ) * 2 >= ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] >= 3 * n / 4 )
                mark = v;
        }
    }
    if( !mark ) return u;
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        for( auto v : t[centroid] ){
            dfs_2(v,centroid,++cnt);
        }
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] > 3 * n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] > n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] > 3 * n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}