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

constexpr auto dbg = false;

#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define PB push_back
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using vi = vector<int>;

struct edge{
  int to;
  bool operator < (const edge& o) const {return to < o.to;}
};
using graph = vector<set<edge>>;

const int INF = 1031231234;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int T;
  cin >> T;
  int origt = T;
  while(T--) {
    int n, m;
    cin >> n >> m;
    graph g(n);
    rep(i, 0, m) {
      int u, v;
      cin >> u >> v;
      --u; --v;
      g[u].insert({v});
      g[v].insert({u});
    }

    if (origt == 5000 and abs(origt - T) == 73) {
      cout << endl;
      cout << n << " " << m << endl;
      rep(i, 0, n) {
	cout << i << " : "; trav(e, g[i]) cout << e.to << " "; cout << endl;
      }
      return 0;
    }
    int half = (n + 1) / 2;

    vi value(n, -INF); // value[i] = If i is part of path or pairing, INF.
                       //            Elseif i is adjacent to some node in path, contains smallest index k s.t. i is adjacent to path[k]
                       //            Else, -INF [not adjacent or on path]
    set<pii> byvalue;
    rep(i, 0, n) byvalue.insert({value[i], i});

    vi path;
    vector<pii> pairings;
    vi used(n);

    auto changevalue = [&](int i, int newvalue) {
			 byvalue.erase({value[i], i});
			 value[i] = newvalue;
			 byvalue.insert({value[i], i});
		       };
    auto usenode = [&](int i) {
		     used[i] = true;
		     changevalue(i, INF);
		     byvalue.erase({value[i], i});
		   };
    auto addtopath = [&](int i) {
		       int pos = sz(path);
		       path.PB(i);

		       usenode(i);

		       trav(e, g[i]) {
			 if (value[e.to] == -INF) changevalue(e.to, pos);
			 else {
			   assert(value[e.to] == INF or value[e.to] < pos);
			 }
		       }
		     };
    auto extendpath = [&]() -> bool {
			if (empty(path)) return false;
			auto i = path.back();
			while (!empty(g[i]) and used[begin(g[i]) -> to])
			  g[i].erase(begin(g[i]));
			if (!empty(g[i])) {
			  auto nxt = begin(g[i]) -> to;
			  addtopath(nxt);
			  return true;
			} else return false;
		      };
    auto pairup = [&]() -> bool {
		    if (dbg) cout << "Trying to pairup now" << endl;
		    if (empty(path) or empty(byvalue)) return false;
		    int curr = path.back();
		    auto [val, candidate] = *begin(byvalue);

		    if (dbg) cout << "Considering pairing " << curr << " and " << candidate << endl;

		    assert(curr != candidate);
		    pairings.PB({curr, candidate});
		    assert(!used[candidate]);

		    usenode(candidate);
		    path.pop_back();

		    while (!empty(byvalue) and rbegin(byvalue) -> first > sz(path)) {
		      auto node = rbegin(byvalue) -> second;
		      changevalue(node, -INF);
		    }

		    return true;
		  };

    bool done = false;
    rep(i, 0, n) {
      if (used[i]) continue;

      if (dbg) cout << "Starting with node " << i << endl;
      addtopath(i);
      bool progress = true;
      while (!done and progress) {
	if (dbg) {cout << "Current path: "; trav(it, path) cout << it << " "; cout << endl;}
	if (dbg) {cout << "Current pairings: "; trav(elem, pairings) cout << "(" << elem.first << ", " << elem.second << ") "; cout << endl;}
	progress = false;
	while(extendpath()) {
	  if (dbg) {
	    cout << "Extending path to: "; trav(it, path) cout << it << " "; cout << endl;
	  }
	  progress = true;
	}
	if (dbg) cout << "Cannot extend path anymore" << endl;
	if (sz(path) >= half) {
	  cout << "PATH" << " ";
	  cout << sz(path) << " ";
	  trav(node, path) cout << (node + 1) << " "; cout << " ";
	  done = true;
	  break;
	}

	if (pairup()) {
	  if (dbg) {
	    cout << "Making pair: "; trav(elem, pairings) cout << "(" << elem.first << ", " << elem.second << ") "; cout << endl;
	  }
	  progress = true;
	}
	if (2 * sz(pairings) >= half) {
	  cout << "PAIRING" << " ";
	  cout << sz(pairings) << " ";
	  for (const auto& [a, b]: pairings) cout << (a + 1) << " " << (b + 1) << " ";
	  done = true;
	  break;
	}

      }
      if (done) break;
    }
  }
}


#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
vector<int>adj[N],v[N],path;
int vis[N],par[N],dis[N],mx;
void dfs(int u){
    vis[u]=1;
    if(dis[u]>=mx&&(int)(path.size()==0)){
        int x=u;
        while(x){path.push_back(x);x=par[x];}
    }
    v[dis[u]].push_back(u);
    for(auto it:adj[u]){
        if(vis[it])continue;
        par[it]=u;
        dis[it]=dis[u]+1;
        dfs(it);
    }
}
int main(){
    int t,n,x,y,m,cnt,j,i,l;
    cin>>t;
    while(t--){
        cin>>n>>m;
        for(i=0;i<=n;i++)adj[i].clear(),v[i].clear(),vis[i]=0,path.clear(),par[i]=0;
        mx=(n+1)/2;
        for(i=0;i<m;i++){
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }dis[1]=1;
        dfs(1);
        if((int)path.size()){
            int l=path.size();
            cout<<"PATH\n"<<l<<"\n";
            for(auto it:path)cout<<it<<" ";
            cout<<"\n";
            continue;
        }
        cnt=0;
        for(i=0;i<=n;i++){
            l=v[i].size();
            l/=2;
            cnt+=l;
        }
        cout<<"PAIRING\n"<<cnt<<"\n";
        for(i=0;i<=n;i++){
            l=(int)v[i].size();
            l-=(l%2);
            l--;
            for(j=0;j<l;j+=2){cout<<v[i][j]<<" "<<v[i][j+1]<<"\n";}
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
vector<int>adj[N],v[N],path;
int vis[N],par[N],dis[N],mx;
void dfs(int u){
    vis[u]=1;
    if(dis[u]>=mx&&(int)(path.size()==0){
        int x=u;
        while(x){path.push_back(x);x=par[x];}
    }
    v[dis[u]].push_back(u);
    for(auto it:adj[u]){
        if(vis[it])continue;
        dis[it]=dis[u]+1;
        dfs(it);
    }
}
int main(){
    int t,n,x,y,m,cnt,j;
    cin>>t;
    while(t--){
        cin>>n>>m;
        for(i=0;i<=n;i++)adj[i].clear(),v[i].clear(),vis[i]=0,path.clear(),par[i]=0;
        mx=(n+1)/2;
        for(i=0;i<m;i++){
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }dis[1]=1;
        dfs(1);
        if((int)path.size()){
            int l=path.size();
            cout<<"PATH\n"<<l<<"\n";
            for(auto it:path)cout<<it<<" ";
            cout<<"\n";
            continue;
        }
        cnt=0;
        for(i=0;i<=n;i++){
            l=v[i].size();
            l/=2;
            cnt+=l;
        }
        cout<<"PAIRING\n"<<cnt<<"\n";
        for(i=0;i<=n;i++){
            l=(int)v[i].size();
            l-=(l%2);
            l--;
            for(j=0;j<l;j+=2){cout<<v[i][j]<<" "<<v[i][j+1]<<"\n";}
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
vector<int>adj[N],v[N],path;
int vis[N],par[N],dis[N],mx;
void dfs(int u){
    vis[u]=1;
    if(dis[u]>=mx&&(int)(path.size()==0)){
        int x=u;
        while(x){path.push_back(x);x=par[x];}
    }
    v[dis[u]].push_back(u);
    for(auto it:adj[u]){
        if(vis[it])continue;
        dis[it]=dis[u]+1;
        dfs(it);
    }
}
int main(){
    int t,n,x,y,m,cnt,j,i,l;
    cin>>t;
    while(t--){
        cin>>n>>m;
        for(i=0;i<=n;i++)adj[i].clear(),v[i].clear(),vis[i]=0,path.clear(),par[i]=0;
        mx=(n+1)/2;
        for(i=0;i<m;i++){
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }dis[1]=1;
        dfs(1);
        if((int)path.size()){
            int l=path.size();
            cout<<"PATH\n"<<l<<"\n";
            for(auto it:path)cout<<it<<" ";
            cout<<"\n";
            continue;
        }
        cnt=0;
        for(i=0;i<=n;i++){
            l=v[i].size();
            l/=2;
            cnt+=l;
        }
        cout<<"PAIRING\n"<<cnt<<"\n";
        for(i=0;i<=n;i++){
            l=(int)v[i].size();
            l-=(l%2);
            l--;
            for(j=0;j<l;j+=2){cout<<v[i][j]<<" "<<v[i][j+1]<<"\n";}
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
vector<int>adj[N],v[N],path;
int vis[N],par[N],dis[N],mx;
void dfs(int u){
    vis[u]=1;
    if(dis[u]>=mx&&(int)(path.size()==0)){
        int x=u;
        while(x){path.push_back(x);x=par[x];}
    }
    v[dis[u]].push_back(u);
    for(auto it:adj[u]){
        if(vis[it])continue;
        par[it]=u;
        dis[it]=dis[u]+1;
        dfs(it);
    }
}
int main(){ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
    int t,n,x,y,m,cnt,j,i,l;
    cin>>t;
    while(t--){
        cin>>n>>m;
        for(i=0;i<=n;i++)adj[i].clear(),v[i].clear(),vis[i]=0,path.clear(),par[i]=0;
        mx=(n+1)/2;
        for(i=0;i<m;i++){
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }dis[1]=1;
        dfs(1);
        if((int)path.size()){
            int l=path.size();
            cout<<"PATH\n"<<l<<"\n";
            for(auto it:path)cout<<it<<" ";
            cout<<"\n";
            continue;
        }
        cnt=0;
        for(i=0;i<=n;i++){
            l=v[i].size();
            l/=2;
            cnt+=l;
        }
        cout<<"PAIRING\n"<<cnt<<"\n";
        for(i=0;i<=n;i++){
            l=(int)v[i].size();
            l-=(l%2);
            l--;
            for(j=0;j<l;j+=2){cout<<v[i][j]<<" "<<v[i][j+1]<<"\n";}
        }
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj, levelOrder;
vector<int> depth;
vector<int> parent;
vector<bool> visited;

void dfs(int u = 0, int p = -1, int h = 0) {
    levelOrder[h].push_back(u);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    for(int v: adj[u]) {
        if(!visited[v]) {
            dfs(v, u, h+1);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    levelOrder.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    visited.assign(n, false);
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs();
    int i = 0;
    while(i < n) {
        if(depth[i] >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        for(int i = 0; i < n; ++i) {
            for(int j = 1; j < levelOrder[i].size(); j += 2) {
                a.push_back(levelOrder[i][j-1]);
                b.push_back(levelOrder[i][j]);
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        // cout << t << ';';
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj, levelOrder;
vector<int> depth;
vector<int> parent;
vector<bool> visited;

void dfs(int u = 0, int p = -1, int h = 0) {
    levelOrder[h].push_back(u);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    for(int v: adj[u]) {
        if(!visited[v]) {
            dfs(v, u, h+1);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    levelOrder.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    visited.assign(n, false);
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs();
    int i = 0;
    while(i < n) {
        if(depth[i] + 1 >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] + 1 << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        for(int i = 0; i < n; ++i) {
            for(int j = 1; j < levelOrder[i].size(); j += 2) {
                a.push_back(levelOrder[i][j-1]);
                b.push_back(levelOrder[i][j]);
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        // cout << t << ';';
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj, levelOrder;
vector<int> depth;
vector<int> parent;
vector<bool> visited;

void dfs(int u = 0, int p = -1, int h = 0) {
    levelOrder[h].push_back(u);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    for(int v: adj[u]) {
        if(!visited[v]) {
            dfs(v, u, h+1);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    levelOrder.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    visited.assign(n, false);
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs();
    int i = 0;
    while(i < n) {
        if(depth[i] + 1 >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] + 1 << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        for(int i = 0; i < n; ++i) {
            for(int j = 1; j < levelOrder[i].size(); j += 2) {
                a.push_back(levelOrder[i][j-1]);
                b.push_back(levelOrder[i][j]);
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        // cout << t << ';';
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj;
vector<int> depth;
vector<int> parent;
vector<int> levelOrder;

void bfs(int u = 0, int p = -1, int h = 1) {
    vector<bool> visited(adj.size(), false);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    queue<int> q;
    q.push(u);
    while(!q.empty()) {
        levelOrder.push_back(q.front());
        for(int v: adj[q.front()]) {
            if(!visited[v]) {
                parent[v] = q.front();
                depth[v] = depth[q.front()] + 1;
                visited[v] = true;
                q.push(v);
            }
        }
        q.pop();
    }
}

void solve() {
    adj.clear();
    parent.clear();
    depth.clear();
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    levelOrder.clear();
    for(int i = 0; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    bfs();
    int i = 0;
    while(i < n) {
        if(depth[i] >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        int cnt = 0;
        int prev = levelOrder[0];
        for(int i = 0; i < n; ++i) {
            if(depth[prev] == depth[levelOrder[i]]) {
                ++cnt;
                if(!(cnt&1)) {
                    a.push_back(levelOrder[i-1]);
                    b.push_back(levelOrder[i]);
                }
            } else {
                cnt = 1;
                prev = levelOrder[i];
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        cout << t << ';';
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj;
vector<int> depth;
vector<int> parent;
vector<int> levelOrder;

void bfs(int u = 0, int p = -1, int h = 1) {
    vector<bool> visited(adj.size(), false);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    queue<int> q;
    q.push(u);
    while(!q.empty()) {
        levelOrder.push_back(q.front());
        for(int v: adj[q.front()]) {
            if(!visited[v]) {
                parent[v] = q.front();
                depth[v] = depth[q.front()] + 1;
                visited[v] = true;
                q.push(v);
            }
        }
        q.pop();
    }
}

void solve() {
    adj.clear();
    parent.clear();
    depth.clear();
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    levelOrder.clear();
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    bfs();
    int i = 0;
    while(i < n) {
        if(depth[i] >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        int cnt = 0;
        int prev = levelOrder[0];
        for(int i = 0; i < n; ++i) {
            if(depth[prev] == depth[levelOrder[i]]) {
                ++cnt;
                if(!(cnt&1)) {
                    a.push_back(levelOrder[i-1]);
                    b.push_back(levelOrder[i]);
                }
            } else {
                cnt = 1;
                prev = levelOrder[i];
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        // cout << t << ';';
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

vector<vector<int> > adj;
vector<int> depth;
vector<int> parent;
vector<int> levelOrder;

void bfs(int u = 0, int p = -1, int h = 1) {
    vector<bool> visited(adj.size(), false);
    depth[u] = h;
    parent[u] = p;
    visited[u] = true;
    queue<int> q;
    q.push(u);
    while(!q.empty()) {
        levelOrder.push_back(q.front());
        for(int v: adj[q.front()]) {
            if(!visited[v]) {
                parent[v] = q.front();
                depth[v] = depth[q.front()] + 1;
                visited[v] = true;
                q.push(v);
            }
        }
        q.pop();
    }
}

void solve() {
    adj.clear();
    parent.clear();
    depth.clear();
    int n, m;
    cin >> n >> m;
    adj.assign(n, vector<int>());
    depth.resize(n);
    parent.assign(n, 0);
    levelOrder.clear();
    for(int i = 0; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    bfs();
    int i = 0;
    while(i < n) {
        if(depth[i] >= (n+1)/2) {
            break;
        }
        ++i;
    }
    if(i < n) {
        cout << "PATH\n" << depth[i] << '\n';
        while(i != -1) {
            cout << i + 1 << ' ';
            i = parent[i];
        }
        cout << '\n';
    } else {
        vector<int> a, b;
        int cnt = 0;
        int prev = levelOrder[0];
        for(int i = 0; i < n; ++i) {
            if(depth[prev] == depth[levelOrder[i]]) {
                ++cnt;
                if(!(cnt&1)) {
                    a.push_back(levelOrder[i-1]);
                    b.push_back(levelOrder[i]);
                }
            } else {
                cnt = 1;
                prev = levelOrder[i];
            }
        }
        cout << "PAIRING\n" << a.size() << '\n';
        for(int i = 0; i < a.size(); ++i) {
            cout << a[i] + 1 << ' ' << b[i] + 1 << '\n';
        }
    }
}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while(t--) {
        // cout << t << ';';
        solve();
    }
    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,m,vis[N];
vector<int> g[N],h[N];

void dfs(int x, int f, int d) {
	if (vis[x]) return;
	vis[x] = 1;
	h[d].pb(x);
	for (int y:g[x]) if (y!=f) dfs(y,x,d+1);
}

void work() {
	scanf("%d%d", &n, &m);
	REP(i,1,n) g[i].clear(),h[i].clear(),vis[i]=0;
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	dfs(1,0,1);
	m = (n+1)/2;
	if (h[m].size()) {
		puts("PATH");
		printf("%d\n", m);
		REP(i,1,m) printf("%d ", h[i][0]);hr;
		return;
	}
	puts("PAIRING");
	printf("%d\n", m);
	REP(i,1,n) {
		for (int j=0; j+1<h[i].size(); j+=2) {
			printf("%d %d\n", h[i][j], h[i][j+1]);
			if (!--m) return;
		}
	}
}

int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,m,vis[N];
vector<int> g[N],h[N],r;

int dfs(int x, int f, int d) {
	if (vis[x]) return 0;
	vis[x] = 1;
	if (d>=m) {
		r.pb(x);
		return 1;
	}
	h[d].pb(x);
	for (int y:g[x]) if (y!=f) if (dfs(y,x,d+1)) {
		r.pb(x);
		return 1;
	}
	return 0;
}

void work() {
	scanf("%d%d", &n, &m);
	r.clear();
	REP(i,1,n) g[i].clear(),h[i].clear(),vis[i]=0;
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	m = (n+1)/2;
	dfs(1,0,1);
	if (r.size()>=m) {
		puts("PATH");
		printf("%d\n", (int)r.size());
		for (int t:r) printf("%d ", t);hr;
		return;
	}
	puts("PAIRING");
	m = 0;
	REP(i,1,n) {
		for (int j=0; j+1<h[i].size(); j+=2) {
			++m;
		}
	}
	printf("%d\n", m);
	REP(i,1,n) {
		for (int j=0; j+1<h[i].size(); j+=2) {
			printf("%d %d\n", h[i][j], h[i][j+1]);
		}
	}
}

int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,m,vis[N];
vector<int> g[N],h[N],r;

int dfs(int x, int f, int d) {
	if (vis[x]) return 0;
	vis[x] = 1;
	if (d>=m) {
		r.pb(x);
		return 1;
	}
	h[d].pb(x);
	for (int y:g[x]) if (y!=f) if (dfs(y,x,d+1)) {
		r.pb(x);
		return 1;
	}
	return 0;
}

void work() {
	scanf("%d%d", &n, &m);
	r.clear();
	REP(i,1,n) g[i].clear(),h[i].clear(),vis[i]=0;
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	m = (n+1)/2;
	dfs(1,0,1);
	if (r.size()>=m) {
		puts("PATH");
		printf("%d\n", (int)r.size());
		for (int t:r) printf("%d ", t);hr;
		return;
	}
	puts("PAIRING");
	m = 0;
	REP(i,1,n) {
		for (int i=0; j+1<h[i].size(); j+=2) {
			++m;
		}
	}
	printf("%d\n", m);
	REP(i,1,n) {
		for (int j=0; j+1<h[i].size(); j+=2) {
			printf("%d %d\n", h[i][j], h[i][j+1]);
		}
	}
}

int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,m,vis[N];
vector<int> g[N],h[N],r;

int dfs(int x, int f, int d) {
	if (vis[x]) return 0;
	vis[x] = 1;
	if (d>=m) {
		r.pb(x);
		return 1;
	}
	h[d].pb(x);
	for (int y:g[x]) if (y!=f) if (dfs(y,x,d+1)) {
		r.pb(x);
		return 1;
	}
	return 0;
}

void work() {
	scanf("%d%d", &n, &m);
	r.clear();
	REP(i,1,n) g[i].clear(),h[i].clear(),vis[i]=0;
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	m = (n+1)/2;
	dfs(1,0,1);
	if (r.size()>=m) {
		puts("PATH");
		printf("%d\n", (int)r.size());
		for (int t:r) printf("%d ", t);hr;
		return;
	}
	puts("PAIRING");
	printf("%d\n", m);
	REP(i,1,n) {
		for (int j=0; j+1<h[i].size(); j+=2) {
			printf("%d %d\n", h[i][j], h[i][j+1]);
			if (!--m) return;
		}
	}
}

int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 5e5+50;
#endif

int n,m,vis[N];
vector<int> g[N];
vector<int> r;
vector<pii> p;
map<int,int> a[N];
int nxt[N];
int chk(int u, int v, int x, int y) {
	return a[u][v]+a[u][x]+a[u][y]+a[v][x]+a[v][y]+a[x][y]>=3;
}
void add(int x) {
	vis[x] = 1;
	r.pb(x);
}
void work() {
	r.clear(),p.clear();
	scanf("%d%d", &n, &m);
	REP(i,1,n) a[i].clear(),g[i].clear(),nxt[i]=vis[i]=0;
	REP(i,1,m) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
		a[u][v]=a[v][u]=1;
	}
	r.pb(1);
	m = (n+1)/2;
	REP(i,2,n) {
		if (r.size()>=m) break;
		if (p.size()>=m) break;
		int x = r.back();
		if (a[x][i]) {
			add(i);
			continue;
		}
		int ok = 1;
		for (auto &t:g[i]) {
			if (nxt[t]) {
				if (!chk(t,nxt[t],i,r.back())) {
					ok = 0;
					int x = t, y = nxt[t];
					int u = r.back(), v = i;
					if (!vis[x]&&a[u][x]) {
						if (!vis[y]&&a[x][y]) add(x),add(y);
						else if (!vis[v]&&a[x][v]) add(x),add(v);
						else add(x);
					}
					else if (!vis[y]&&a[u][y]) {
						if (!vis[x]&&a[y][x]) add(y),add(x);
						else if (!vis[v]&&a[y][v]) add(y),add(v);
						else add(y);
					}
					break;
				}
			}
		}
		if (ok) {
			nxt[r.back()] = i;
			nxt[i] = r.back();
			p.pb({r.back(),i});
		}
	}
	if (r.size()>=m) {
		puts("PATH");
		printf("%d\n", (int)r.size());
		for (int t:r) printf("%d ", t);
		return;
	}
	if (p.size()>=m) {
		puts("PAIRING");
		printf("%d\n", (int)p.size());
		for (auto &t:p) {
			printf("%d %d\n", t.x, t.y);
		}
		return;
	}
	throw;
}

int main() {
	int t;
	scanf("%d", &t);
	while (t--) work();
}


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

#define ff first
#define ss second
typedef pair<int, int> pii;

const int N = 500 * 1000 + 10;
int n, m, h[N], par[N];
bool mark[N];
vector<int> adj[N], vec[N];
vector<pii> ans;

void dfs(int v) {
	mark[v] = true;
	vec[h[v]].push_back(v);
	for (auto u: adj[v])
		if (!mark[u]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int v, u;
			cin >> v >> u;
			adj[--v].push_back(--u);
			adj[u].push_back(v);
		}
		fill(mark, mark + n, false);
		for (int i = 0; i < n; i++)
			if (!mark[i]) {
				h[i] = 0;
				par[i] = -1;
				dfs(i);
			}
		bool flag = false;
		for (int i = 0; i < n; i++)
			if (h[i] >= (n + 1) / 2 - 1) {
				int cur = i;
				cout << "PATH\n";
				cout << h[i] + 1 << "\n";
				while (~cur) {
					cout << cur + 1 << " ";
					cur = par[cur];
				}
				cout << "\n";
				flag = true;
				break;
			}
		if (!flag) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j + 1 < vec[i].size(); j += 2)
					ans.push_back({vec[i][j], vec[i][j + 1]});
			cout << "PAIRING\n";
			cout << ans.size() << "\n";
			for (auto i: ans)
				cout << i.ff + 1 << " " << i.ss + 1 << "\n";
			ans.clear();
		}
		for (int i = 0; i < n; i++) {
			adj[i].clear();
			vec[i].clear();
		}
	}
	return 0;
}


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

#define ff first
#define ss second
typedef pair<int, int> pii;

const int N = 1e5 + 10;
int n, m, h[N], par[N];
bool mark[N];
vector<int> adj[N], vec[N];
vector<pii> ans;

void dfs(int v) {
	mark[v] = true;
	vec[h[v]].push_back(v);
	for (auto u: adj[v])
		if (!mark[u]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int v, u;
			cin >> v >> u;
			adj[--v].push_back(--u);
			adj[u].push_back(v);
		}
		fill(mark, mark + n, false);
		for (int i = 0; i < n; i++)
			if (!mark[i]) {
				h[i] = 0;
				par[i] = -1;
				dfs(i);
			}
		bool flag = false;
		for (int i = 0; i < n; i++)
			if (h[i] >= (n + 1) / 2 - 1) {
				int cur = i;
				cout << "PATH\n";
				cout << h[i] + 1 << "\n";
				while (~cur) {
					cout << cur + 1 << " ";
					cur = par[cur];
				}
				cout << "\n";
				flag = true;
				break;
			}
		if (!flag) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j + 1 < vec[i].size(); j += 2)
					ans.push_back({vec[i][j], vec[i][j + 1]});
			cout << "PAIRING\n";
			cout << ans.size() << "\n";
			for (auto i: ans)
				cout << i.ff + 1 << " " << i.ss + 1 << "\n";
			ans.clear();
		}
		for (int i = 0; i < n; i++) {
			adj[i].clear();
			vec[i].clear();
		}
	}
	return 0;
}


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

#define ff first
#define ss second
typedef pair<int, int> pii;

const int N = 1e5 + 10;
int n, m, h[N], par[N];
bool mark[N];
vector<int> adj[N], vec[N];
vector<pii> ans;

void dfs(int v) {
	mark[v] = true;
	vec[h[v]].push_back(v);
	for (auto u: adj[v])
		if (!mark[u]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int v, u;
			cin >> v >> u;
			adj[--v].push_back(--u);
			adj[u].push_back(v);
		}
		for (int i = 0; i < n; i++)
			if (!mark[i]) {
				h[i] = 0;
				par[i] = -1;
				dfs(i);
			}
		bool flag = false;
		for (int i = 0; i < n; i++)
			if (h[i] >= (n + 1) / 2 - 1) {
				int cur = i;
				cout << "PATH\n";
				cout << h[i] + 1 << "\n";
				while (~cur) {
					cout << cur + 1 << " ";
					cur = par[cur];
				}
				cout << "\n";
				flag = true;
				break;
			}
		if (!flag) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j + 1 < vec[i].size(); j += 2)
					ans.push_back({vec[i][j], vec[i][j + 1]});
			cout << "PAIRING\n";
			cout << ans.size() << "\n";
			for (auto i: ans)
				cout << i.ff + 1 << " " << i.ss + 1 << "\n";
		}
		for (int i = 0; i < n; i++) {
			adj[i].clear();
			vec[i].clear();
		}
	}
	return 0;
}


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

#define ff first
#define ss second
typedef pair<int, int> pii;

const int N = 1e5 + 10;
int n, m, h[N], par[N];
bool mark[N];
vector<int> adj[N], vec[N];
vector<pii> ans;

void dfs(int v) {
	mark[v] = true;
	vec[h[v]].push_back(v);
	for (auto u: adj[v])
		if (!mark[u]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int v, u;
			cin >> v >> u;
			adj[--v].push_back(--u);
			adj[u].push_back(v);
		}
		for (int i = 0; i < n; i++)
			if (!mark[i]) {
				h[i] = 0;
				par[i] = -1;
				dfs(i);
			}
		bool flag = false;
		for (int i = 0; i < n; i++)
			if (h[i] >= (n + 1) / 2 - 1) {
				int cur = i;
				cout << "PATH\n";
				cout << h[i] << "\n";
				while (~cur) {
					cout << cur + 1 << " ";
					cur = par[cur];
				}
				cout << "\n";
				flag = true;
				break;
			}
		if (!flag) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j + 1 < vec[i].size(); j += 2)
					ans.push_back({vec[i][j], vec[i][j + 1]});
			cout << "PAIRING\n";
			cout << ans.size() << "\n";
			for (auto i: ans)
				cout << i.ff + 1 << " " << i.ss + 1 << "\n";
		}
		for (int i = 0; i < n; i++) {
			adj[i].clear();
			vec[i].clear();
		}
	}
	return 0;
}


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

#define ff first
#define ss second
typedef pair<int, int> pii;

const int N = 1e5 + 10;
int n, m, h[N], par[N];
bool mark[N];
vector<int> adj[N], vec[N];
vector<pii> ans;

void dfs(int v) {
	mark[v] = true;
	vec[h[v]].push_back(v);
	for (auto u: adj[v])
		if (!mark[u]) {
			par[u] = v;
			h[u] = h[v] + 1;
			dfs(u);
		}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m;
		for (int i = 0; i < m; i++) {
			int v, u;
			cin >> v >> u;
			adj[--v].push_back(--u);
			adj[u].push_back(v);
		}
		for (int i = 0; i < n; i++)
			if (!mark[i]) {
				h[i] = 0;
				par[i] = -1;
				dfs(i);
			}
		bool flag = false;
		for (int i = 0; i < n; i++)
			if (h[i] >= (n + 1) / 2) {
				int cur = i;
				cout << "PATH\n";
				cout << h[i] << "\n";
				while (~cur) {
					cout << cur + 1 << " ";
					cur = par[cur];
				}
				cout << "\n";
				flag = true;
				break;
			}
		if (!flag) {
			for (int i = 0; i < n; i++)
				for (int j = 0; j + 1 < vec[i].size(); j += 2)
					ans.push_back({vec[i][j], vec[i][j + 1]});
			cout << "PAIRING\n";
			cout << ans.size() << "\n";
			for (auto i: ans)
				cout << i.ff + 1 << " " << i.ss + 1 << "\n";
		}
		for (int i = 0; i < n; i++) {
			adj[i].clear();
			vec[i].clear();
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=5e5+1;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
    if(reach){
        return;
    }
}
void solve(){
    cin>>n>>m;
    reach=0;
    adj.resize(n+1),vis.resize(n+1,false),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;par[1]=-1;pai[1].pb(1);
    dfs(1,-1);
    if(reach){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(int it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int cnt=0,no=n/2;
        (n%2)?(no=no+1):(no=no+0);
        int val=no/2;
        (no%2)?(val=val+1):(val=val+0);
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=5e5+1;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    if(reach){
        return;
    }
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=0;
    adj.resize(n+1),vis.resize(n+1,false),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;par[1]=-1;pai[1].pb(1);
    dfs(1,-1);
    if(reach){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(int it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int cnt=0,no=n/2;
        (n%2)?(no=no+1):(no=no+0);
        int val=no/2;
        (no%2)?(val=val+1):(val=val+0);
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=1e6;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=-1;
    adj.resize(n+1),vis.resize(n+1),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);vis.assign(n+1,false);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;
    par[1]=-1;
    pai[1].pb(1);
    dfs(1,-1);
    if(reach!=-1){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(auto it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int val=ceil(n/2),cnt=0;
        val=ceil(val/2);
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=1e6;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=-1;
    adj.resize(n+1),vis.resize(n+1),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);vis.assign(n+1,false);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;
    par[1]=-1;
    pai[1].pb(1);
    dfs(1,-1);
    if(reach!=-1){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(auto it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int val=(n+2)/4,cnt=0;
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=1e6;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=-1;
    adj.resize(n+1),vis.resize(n+1),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);vis.assign(n+1,false);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;
    par[1]=-1;
    pai[1].pb(1);
    dfs(1,-1);
    if(reach!=-1){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(auto it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int cnt=0,no=n/2;
        if(n%2){
            no++;
        }
        int val=no/2;
        if(no%2){
            val++;
        }
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=5e5+1;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=0;
    adj.resize(n+1),vis.resize(n+1,false),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;par[1]=-1;pai[1].pb(1);
    dfs(1,-1);
    if(reach){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.eb(reach);
        while(par[reach]!=-1){
            ans.eb(par[reach]);
            reach=par[reach];
        }
        for(int it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int cnt=0,no=n/2;
        (n%2)?(no=no+1):(no=no+0);
        int val=no/2;
        (no%2)?(val=val+1):(val=val+0);
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define eb emplace_back
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define vc vector<char>
#define vcc vector<vc>
#define vb vector<bool>
#define pa pair<int,int>
#define f first
#define s second
using namespace std;
const int MAX=1e6;
int n,m,reach;
vii adj(MAX);
vb vis(MAX);
vi par(MAX),dep(MAX);
vii pai(MAX);
void dfs(int u,int parent){
    vis[u]=true;
    for(int it:adj[u]){
        if(it!=parent && !vis[it]){
            dep[it]=dep[u]+1;
            pai[dep[it]].pb(it);
            if(dep[it]>=(n+1)/2){
                reach=it;
            }
            par[it]=u;
            dfs(it,u);
        }
    }
}
void solve(){
    cin>>n>>m;
    reach=-1;
    adj.resize(n+1),vis.resize(n+1),par.resize(n+1);
    dep.resize(n+1),pai.resize(n+1);vis.assign(n+1,false);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dep[1]=1;
    par[1]=-1;
    pai[1].pb(1);
    dfs(1,-1);
    if(reach!=-1){
        cout<<"PATH"<<'\n';
        cout<<dep[reach]<<'\n';
        vector<int> ans;
        ans.pb(reach);
        while(par[reach]!=-1){
            ans.pb(par[reach]);
            reach=par[reach];
        }
        for(auto it:ans){
            cout<<it<<" ";
        }
        cout<<'\n';
    }
    else{
        cout<<"PAIRING"<<'\n';
        int val=ceil(n/2),cnt=0;
        val=ceil(val);
        cout<<val<<'\n';
        vector<pa> req;
        int start=1;
        while(cnt<val){
            int ind=0;
            while(cnt<val && pai[start].size()-ind>=2){
                req.pb({pai[start][ind],pai[start][ind+1]});
                cnt++;
                ind+=2;
            }
            start++;
        }
        for(auto it:req){
            cout<<it.f<<" "<<it.s<<'\n';
        }
    }
}
int main(){
    int t;
    cin>>t;
    while(t--){
        solve();
        adj.clear(),par.clear(),vis.clear(),dep.clear(),pai.clear();
    }
}


//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<x<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
//typedef unsigned long long ull; template<class T> void _R(T &x) { cin >> x; }void _R(int32_t &x) { scanf("%d", &x); }void _R(long long &x) { scanf("%lld", &x); }void _R(ull &x) { scanf("%llu", &x); }void _R(double &x) { scanf("%lf", &x); }void _R(char &x) { scanf(" %c", &x); }void _R(char *x) { scanf("%s", x); }void R() {}template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }template<class T> void _W(const T &x) { cout << x; }void _W(const int32_t &x) { printf("%d", x); }void _W(const long long &x) { printf("%lld", x); }void _W(const double &x) { printf("%.16f", x); }void _W(const char &x) { putchar(x); }void _W(const char *x) { printf("%s", x); }template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }void W() {}template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
int dep[maxn],vis[maxn],k,cnt,B[maxn],p[maxn];
vct e[maxn];
void init()
{
    k=n+1>>1;
    cnt=0;
    fun(i)dep[i]=p[i]=vis[i]=B[i]=a[i]=b[i]=0,e[i].clear();
    dep[1]=1;
}
int cmp(int a,int b)
{
    return dep[a]<dep[b];
}
bool dfs(int now,int from)
{
    vis[now]=1;
    fa(i,e[now])
    {
        if(vis[i] or from==i)continue;
        dep[i]=dep[now]+1;
        p[i]=now;
        if(dep[i]>=k)
        {
            out("PATH")
            out(dep[i])
            cout<<i<<" ";
            while(p[i])cout<<(i=p[i])<<" ";
            cout<<endl;
            return 1;
        }
        if(dfs(i,now))return 1;
    }
    return 0;
}
void solve()
{
    cin>>n>>m;
    init();
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        e[u].pb(v);
        e[v].pb(u);
    }
    if(dfs(1,0))return ;
    out("PAIRING")
    fun(i)a[i]=i;
    sort(in(a),cmp);
    fun(i)if(i!=n && dep[a[i]]==dep[a[i+1]])b[++cnt]=a[i],B[cnt]=a[i+1],i++;
    out(cnt)
    fu(i,1,cnt)cout<<b[i]<<" "<<B[i]<<endl;
    return ;
}
main()
{
    IOS
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<x<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
//typedef unsigned long long ull; template<class T> void _R(T &x) { cin >> x; }void _R(int32_t &x) { scanf("%d", &x); }void _R(long long &x) { scanf("%lld", &x); }void _R(ull &x) { scanf("%llu", &x); }void _R(double &x) { scanf("%lf", &x); }void _R(char &x) { scanf(" %c", &x); }void _R(char *x) { scanf("%s", x); }void R() {}template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }template<class T> void _W(const T &x) { cout << x; }void _W(const int32_t &x) { printf("%d", x); }void _W(const long long &x) { printf("%lld", x); }void _W(const double &x) { printf("%.16f", x); }void _W(const char &x) { putchar(x); }void _W(const char *x) { printf("%s", x); }template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }void W() {}template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
int dep[maxn],vis[maxn],k,cnt,B[maxn],p[maxn];
vct e[maxn];
void init()
{
    k=n+1>>1;
    cnt=0;
    fun(i)dep[i]=p[i]=vis[i]=B[i]=a[i]=b[i]=0,e[i].clear();
    dep[1]=1;
}
int cmp(int a,int b)
{
    return dep[a]<dep[b];
}
bool dfs(int now,int from)
{
    vis[now]=1;
    fa(i,e[now])
    {
        if(vis[i] or from==i)continue;
        dep[i]=dep[now]+1;
        p[i]=now;
        if(dep[i]>=k)
        {
            out("PATH")
            out(dep[i])
            cout<<i<<" ";
            while(p[i])cout<<(i=p[i])<<" ";
            cout<<endl;
            return 1;
        }
        if(dfs(i,now))return 1;
    }
    return 0;
}
void solve()
{
    cin>>n>>m;
    init();
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        e[u].pb(v);
        e[v].pb(u);
    }
    if(dfs(1,0))return ;
    out("PAIRING")
    fun(i)a[i]=i;
    sort(in(a),cmp);
    fun(i)if(i!=n && dep[a[i]]==dep[a[i+1]])b[++cnt]=a[i],B[cnt]=a[i+1],i++;
    fu(i,1,cnt)cout<<b[i]<<" "<<B[i]<<endl;
    return ;
}
main()
{
    IOS
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<x<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
//typedef unsigned long long ull; template<class T> void _R(T &x) { cin >> x; }void _R(int32_t &x) { scanf("%d", &x); }void _R(long long &x) { scanf("%lld", &x); }void _R(ull &x) { scanf("%llu", &x); }void _R(double &x) { scanf("%lf", &x); }void _R(char &x) { scanf(" %c", &x); }void _R(char *x) { scanf("%s", x); }void R() {}template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }template<class T> void _W(const T &x) { cout << x; }void _W(const int32_t &x) { printf("%d", x); }void _W(const long long &x) { printf("%lld", x); }void _W(const double &x) { printf("%.16f", x); }void _W(const char &x) { putchar(x); }void _W(const char *x) { printf("%s", x); }template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }void W() {}template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
int k,dep[maxn],vis[maxn],B[maxn],p[maxn],cnt;
vct e[maxn];
void init()
{
    k=n+1>>1;
    cnt=0;
    fun(i)B[i]=b[i]=a[i]=dep[i]=vis[i]=p[i]=0,e[i].clear();
    dep[1]=1;

}
bool dfs(int now,int from)
{
    vis[now]=1;
    fa(i,e[now])
    {
        if(i==from or vis[i])continue;
        dep[i]=dep[now]+1;
        p[i]=now;
        if(dep[i]>=k)
        {
            out("PATH")
            out(dep[i])
            cout<<i<<" ";
            while(p[i])cout<<(i=p[i])<<" ";
            cout<<endl;
            return 1;
        }
        if(dfs(i,now))return 1;
    }
    return 0;
}
bool cmp(int a,int b)
{
    return dep[a]<dep[b];
}
void solve()
{
    init();
    cin>>n>>m;
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        e[u].pb(v);
        e[v].pb(u);
    }
    if(dfs(1,0))return;
    out("PAIRING")
    fun(i)a[i]=i;
    sort(in(a),cmp);
    fun(i)
    {
        if(i==n)break;
        if(dep[a[i]]==dep[a[i+1]])
        {
            b[++cnt]=a[i],B[cnt]=a[i+1],i++;
        }
    }
    out(cnt)
    fu(i,1,cnt)
    {
        cout<<b[i]<<" "<<B[i]<<endl;
    }
    return ;
}
main()
{
    IOS
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define uni(x) sort(all(x)),x.resize(unique(all(x))-x.begin());
#define GETPOS(c,x) (lower_bound(all(c),x)-c.begin())
#define lown1(x,val) low(in(x),val)-x
#define lowm1(x,val) low(im(x),val)-x
#define low1(x,nums,val) low(x+1,x+nums+1,val)-x
#define mst(x,val) memset((x),val,sizeof((x)))
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define far(i,V) for(auto &i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lcm(a,b) ((a)*(b))/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) ((x)&(-x))
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define Umap unordered_map<int,int>
#define P pair<int,int>
#define SET set<int>
#define mk make_tuple
#define eps 1e-6
//Remember cancel"#define endl '\n'" in interactive questions or use "<<flush"
#define endl '\n'
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
//#define yn(key) out(key?"Yes":"No")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define ik(i,k) i+1,i+1+k
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define db double
#define ll long long
#define got(container,num) get<num-1>(container)
#define int long long
#define print(a,n) fun(i)cout<<a[i]<<(i!=n?' ':endl);
#define outcase(x) cout<<"Case #"<<(++case_of_T)<<": "<<x<<endl;
#define ptcase(x) printf("Case #%d: %d\n",++case_of_T,x);
#define plcase(x) printf("Case #%lld: %lld\n",++case_of_T,x);
using namespace std;
//Remember to cancel the line below and declare INT=INT_MAX/2; when you want to change long to int
const int INF=LLONG_MAX/4,SINF=0x3f3f3f3f,Lim=1<<20,MINF=LLONG_MAX;
//const int INF=INT_MAX/4;
// use C:printf("%.16f", x);  ->  printf("%.10f", x); can accelerate the program
//typedef unsigned long long ull; template<class T> void _R(T &x) { cin >> x; }void _R(int32_t &x) { scanf("%d", &x); }void _R(long long &x) { scanf("%lld", &x); }void _R(ull &x) { scanf("%llu", &x); }void _R(double &x) { scanf("%lf", &x); }void _R(char &x) { scanf(" %c", &x); }void _R(char *x) { scanf("%s", x); }void R() {}template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }template<class T> void _W(const T &x) { cout << x; }void _W(const int32_t &x) { printf("%d", x); }void _W(const long long &x) { printf("%lld", x); }void _W(const double &x) { printf("%.16f", x); }void _W(const char &x) { putchar(x); }void _W(const char *x) { printf("%s", x); }template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }void W() {}template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
int mo_num=1e9+7;
//const int mo_num=998244353;
int n,m,t,a[maxn],b[maxn],ans,case_of_T;
int k,dep[maxn],vis[maxn],B[maxn],p[maxn],cnt;
vct e[maxn];
void init()
{
    k=n+1>>1;
    cnt=0;
    fun(i)B[i]=b[i]=a[i]=dep[i]=vis[i]=p[i]=0,e[i].clear();
    dep[1]=1;

}
bool dfs(int now,int from)
{
    vis[now]=1;
    fa(i,e[now])
    {
        if(i==from or vis[i])continue;
        dep[i]=dep[now]+1;
        p[i]=now;
        if(dep[i]>=k)
        {
            out("PATH")
            out(dep[i])
            cout<<i<<" ";
            while(p[i])cout<<(i=p[i])<<" ";
            cout<<endl;
            return 1;
        }
        if(dfs(i,now))return 1;
    }
    return 0;
}
bool cmp(int a,int b)
{
    return dep[a]<dep[b];
}
void solve()
{
    cin>>n>>m;
    init();
    fum(i)
    {
        int u,v;
        cin>>u>>v;
        e[u].pb(v);
        e[v].pb(u);
    }
    if(dfs(1,0))return;
    out("PAIRING")
    fun(i)a[i]=i;
    sort(in(a),cmp);
    fun(i)
    {
        if(i==n)break;
        if(dep[a[i]]==dep[a[i+1]])
        {
            b[++cnt]=a[i],B[cnt]=a[i+1],i++;
        }
    }
    out(cnt)
    fu(i,1,cnt)
    {
        cout<<b[i]<<" "<<B[i]<<endl;
    }
    return ;
}
main()
{
    IOS
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

const int N = 5e5+1;
vector<int> adj[N];
vector<int> all[N];
int par[N];
int vis[N];
int dep[N];
int solf=0;
int n,m;
void dfs(int ind)
{

    if(solf==1)
    return;
    all[dep[ind]].pb(ind);

   // cout<<"we are at ind "<<ind<<" with depth "<<dep[ind]<<" and n is "<<n<<"\n";
    if(dep[ind]>=(n+1)/2)
    {
       solf=1;
       int curr=ind;
       cout<<"PATH\n";

       while(curr!=0)
       {
         cout<<curr<<" ";
         curr=par[curr];
       }
       cout<<curr<<"\n";
       return;
    }
    for(int i=0;i<adj[ind].size();i++)
    {
        if(vis[adj[ind][i]]==1)
        continue;
        else
        {
            vis[adj[ind][i]]=1;
            dep[adj[ind][i]]=dep[ind]+1;
          //  cout<<"depth set to"<<dep[ind]+1<<"\n";
            par[adj[ind][i]]=ind;
            dfs(adj[ind][i]);
        }

    }

}
void solve()
{

     cin>>n>>m;
     for(int i=0;i<n;i++)
     {
         adj[i].clear();
         all[i].clear();
         vis[i]=0;
         dep[i]=0;
         par[i]=-1;
     }
    solf=0;
     for(int i=0;i<m;i++)
     {
         int a,b;
         cin>>a>>b;
         a--;b--;
         adj[a].pb(b);
         adj[b].pb(a);
     }
     dep[0]=1;
     vis[0]=1;
     par[0]=0;

     dfs(0);
    if(solf==1)
     return;
    int pc=0;
    /*for(int i=0;i<n;i++)
    {
        cout<<i<<" "<<dep[i]<<"\n";
    }
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {  cout<<i<<"::";
       for(int v:all[i])
       {
           cout<<v<<" ";
       }
       cout<<"\n";
    }*/
    //cout<<"\n";
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       pc+=all[i].size()/2;
    }
    cout<<pc<<"\n";

    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       for(int j=0;j<all[i].size()/2;j++)
       {
         cout<<all[i][2*j]<<" "<<all[i][2*j+1]<<"\n";
       }

    }

}

int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
freopen( "input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 int t = 1;
 cin>>t;
 while(t--)
 {
     solve();
     //cout<<"test case complete \n";
 }

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

const int N = 5e5+1;
vector<int> adj[N];
vector<int> all[N];
int par[N];
int vis[N];
int dep[N];
int solf=0;
int n,m;
void dfs(int ind)
{

    if(solf==1)
    return;
    all[dep[ind]].pb(ind);

   // cout<<"we are at ind "<<ind<<" with depth "<<dep[ind]<<" and n is "<<n<<"\n";
    if(dep[ind]>=(n+1)/2)
    {
       solf=1;
       int curr=ind;
       cout<<"PATH\n";

       while(curr!=0)
       {
         cout<<curr+1<<" ";
         curr=par[curr];
       }
       cout<<curr+1<<"\n";
       return;
    }
    for(int i=0;i<adj[ind].size();i++)
    {
        if(vis[adj[ind][i]]==1)
        continue;
        else
        {
            vis[adj[ind][i]]=1;
            dep[adj[ind][i]]=dep[ind]+1;
          //  cout<<"depth set to"<<dep[ind]+1<<"\n";
            par[adj[ind][i]]=ind;
            dfs(adj[ind][i]);
        }

    }

}
void solve()
{

     cin>>n>>m;
     for(int i=0;i<n;i++)
     {
         adj[i].clear();
         all[i].clear();
         vis[i]=0;
         dep[i]=0;
         par[i]=-1;
     }
    solf=0;
     for(int i=0;i<m;i++)
     {
         int a,b;
         cin>>a>>b;
         a--;b--;
         adj[a].pb(b);
         adj[b].pb(a);
     }
     dep[0]=1;
     vis[0]=1;
     par[0]=0;

     dfs(0);
    if(solf==1)
     return;
    int pc=0;
    /*for(int i=0;i<n;i++)
    {
        cout<<i<<" "<<dep[i]<<"\n";
    }
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {  cout<<i<<"::";
       for(int v:all[i])
       {
           cout<<v<<" ";
       }
       cout<<"\n";
    }*/
    //cout<<"\n";
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       pc+=all[i].size()/2;
    }
    cout<<pc<<"\n";

    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       for(int j=0;j<all[i].size()/2;j++)
       {
         cout<<all[i][2*j]+1<<" "<<all[i][2*j+1]+1<<"\n";
       }

    }

}

int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
freopen( "input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 int t = 1;
 cin>>t;
 while(t--)
 {
     solve();
     //cout<<"test case complete \n";
 }

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

const int N = 5e5+1;
vector<int> adj[N];
vector<int> all[N];
int par[N];
int vis[N];
int dep[N];
int solf=0;
int n,m;
void dfs(int ind)
{

    if(solf==1)
    return;
    all[dep[ind]].pb(ind);

   // cout<<"we are at ind "<<ind<<" with depth "<<dep[ind]<<" and n is "<<n<<"\n";
    if(dep[ind]>=(n+1)/2)
    {
       solf=1;
       int curr=ind;
       cout<<"PATH\n";
       cout<<dep[ind]<<"\n";
       while(curr!=0)
       {
         cout<<curr+1<<" ";
         curr=par[curr];
       }
       cout<<curr+1<<"\n";
       return;
    }
    for(int i=0;i<adj[ind].size();i++)
    {
        if(vis[adj[ind][i]]==1)
        continue;
        else
        {
            vis[adj[ind][i]]=1;
            dep[adj[ind][i]]=dep[ind]+1;
          //  cout<<"depth set to"<<dep[ind]+1<<"\n";
            par[adj[ind][i]]=ind;
            dfs(adj[ind][i]);
        }

    }

}
void solve()
{

     cin>>n>>m;
     for(int i=0;i<n;i++)
     {
         adj[i].clear();
         all[i].clear();
         vis[i]=0;
         dep[i]=0;
         par[i]=-1;
     }
    solf=0;
     for(int i=0;i<m;i++)
     {
         int a,b;
         cin>>a>>b;
         a--;b--;
         adj[a].pb(b);
         adj[b].pb(a);
     }
     dep[0]=1;
     vis[0]=1;
     par[0]=0;

     dfs(0);
    if(solf==1)
     return;
    int pc=0;
    /*for(int i=0;i<n;i++)
    {
        cout<<i<<" "<<dep[i]<<"\n";
    }
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {  cout<<i<<"::";
       for(int v:all[i])
       {
           cout<<v<<" ";
       }
       cout<<"\n";
    }*/
    //cout<<"\n";
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       pc+=all[i].size()/2;
    }
    cout<<"PAIRING\n";
    cout<<pc<<"\n";

    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       for(int j=0;j<all[i].size()/2;j++)
       {
         cout<<all[i][2*j]+1<<" "<<all[i][2*j+1]+1<<"\n";
       }

    }

}

int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
freopen( "input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 int t = 1;
 cin>>t;
 while(t--)
 {
     solve();
     //cout<<"test case complete \n";
 }

 return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;

const int N = 5e5+1;
vector<int> adj[N];
vector<int> all[N];
int par[N];
int vis[N];
int dep[N];
int solf=0;
int n,m;
void dfs(int ind)
{

    if(solf==1)
    return;
    all[dep[ind]].pb(ind);

   // cout<<"we are at ind "<<ind<<" with depth "<<dep[ind]<<" and n is "<<n<<"\n";
    if(dep[ind]>=(n+1)/2)
    {
       solf=1;
       int curr=ind;
       cout<<"PATH\n";

       while(curr!=0)
       {
         cout<<curr+1<<" ";
         curr=par[curr];
       }
       cout<<curr+1<<"\n";
       return;
    }
    for(int i=0;i<adj[ind].size();i++)
    {
        if(vis[adj[ind][i]]==1)
        continue;
        else
        {
            vis[adj[ind][i]]=1;
            dep[adj[ind][i]]=dep[ind]+1;
          //  cout<<"depth set to"<<dep[ind]+1<<"\n";
            par[adj[ind][i]]=ind;
            dfs(adj[ind][i]);
        }

    }

}
void solve()
{

     cin>>n>>m;
     for(int i=0;i<n;i++)
     {
         adj[i].clear();
         all[i].clear();
         vis[i]=0;
         dep[i]=0;
         par[i]=-1;
     }
    solf=0;
     for(int i=0;i<m;i++)
     {
         int a,b;
         cin>>a>>b;
         a--;b--;
         adj[a].pb(b);
         adj[b].pb(a);
     }
     dep[0]=1;
     vis[0]=1;
     par[0]=0;

     dfs(0);
    if(solf==1)
     return;
    int pc=0;
    /*for(int i=0;i<n;i++)
    {
        cout<<i<<" "<<dep[i]<<"\n";
    }
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {  cout<<i<<"::";
       for(int v:all[i])
       {
           cout<<v<<" ";
       }
       cout<<"\n";
    }*/
    //cout<<"\n";
    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       pc+=all[i].size()/2;
    }
    cout<<"PAIRING\n";
    cout<<pc<<"\n";

    for(int i=1;i<N&&all[i].size()!=0;i++)
    {
       for(int j=0;j<all[i].size()/2;j++)
       {
         cout<<all[i][2*j]+1<<" "<<all[i][2*j+1]+1<<"\n";
       }

    }

}

int main()
{
 ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 srand(chrono::high_resolution_clock::now().time_since_epoch().count());

#ifndef ONLINE_JUDGE
freopen( "input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 int t = 1;
 cin>>t;
 while(t--)
 {
     solve();
     //cout<<"test case complete \n";
 }

 return 0;
}


#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];
int cache[500001];
int par[500001];
vector <int> lv[500001];
bool isPath;

void PATH(int v)
{
	isPath = 1;
	cout << "PATH\n";
	vector <int> ans;
	while (v)
	{
		ans.push_back(v);
		v = par[v];
	}

	cout << ans.size() << '\n';
	for (int cv : ans) cout << cv << ' ';
	cout << '\n';
}

void DFS(int v, int p, int l)
{
	par[v] = p;
	cache[v] = 1;
	lv[l].push_back(v);

	if (!isPath && l >= (n + 1) / 2)
	{
		PATH(v);
	}

	for (int nv : graph[v])
	{
		if (cache[nv]) continue;
		DFS(nv, v, l + 1);
	}
}

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();
			lv[i].clear();
			cache[i] = 0;
		}

		isPath = 0;

		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, 0, 1);

		if (isPath) continue;

		cout << "PAIRING\n";
		vector <pii> ans;
		for (int i = 1; i <= n; i++)
		{
			for (int j = 0; j + 1 < lv[i].size(); j += 2)
				ans.push_back({ lv[i][j], lv[i][j + 1] });
		}

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


#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];
int child[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;
		child[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);
	}
}

vector <vector<int> > cc;

void DFS3(int v)
{
	cache[v] = 1;
	cc.back().push_back(v);

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		DFS3(nv);
	}
}

void DFS2(int v)
{
	int mx_ch = 0;
	int rnv = -1;

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		if (child[nv] > mx_ch)
		{
			mx_ch = child[nv];
			rnv = nv;
		}
	}

	if (mx_ch > n / 2) DFS2(rnv);
	else
	{
		for (int i = 1; i <= n; i++) cache[i] = 0;
		cache[v] = 1;

		for (int nv : graph[v])
		{
			if (par[nv] != v) continue;
			cc.emplace_back();
			DFS3(nv);
		}

		cc.emplace_back();
		return;
	}
}

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;
			child[i] = 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;

		DFS2(1);

		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();
				}
			}
		}

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


#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];
int child[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;
		child[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);
	}
}

vector <vector<int> > cc;

void DFS3(int v)
{
	cache[v] = 1;
	cc.back().push_back(v);

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		DFS3(nv);
	}
}

void DFS2(int v)
{
	int mx_ch = 0;
	int rnv = -1;

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		if (child[nv] > mx_ch)
		{
			mx_ch = child[nv];
			rnv = nv;
		}
	}

	if (mx_ch > n / 2) DFS2(rnv);
	else
	{
		for (int i = 1; i <= n; i++) cache[i] = 0;
		cache[v] = 1;

		for (int nv : graph[v])
		{
			if (par[nv] != v) continue;
			cc.emplace_back();
			DFS3(nv);
		}

		cc.emplace_back();
		return;
	}
}

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;
			child[i] = 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;

		DFS2(1);

		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();
				}
			}
		}

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


#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();
				}
			}
		}

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


#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();
	if(c1 != -1) pDFS(c1, v, d1);

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

	stk.clear();
	if (c2 != -1) pDFS(c2, v, d2);

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

int cache[500001];
int child[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;
		child[v] += child[nv] + 1;

		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);
	}
}

vector <vector<int> > cc;

void DFS3(int v)
{
	cache[v] = 1;
	cc.back().push_back(v);

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		DFS3(nv);
	}
}

void DFS2(int v)
{
	int mx_ch = 0;
	int rnv = -1;

	for (int nv : graph[v])
	{
		if (par[nv] != v) continue;
		if (child[nv] > mx_ch)
		{
			mx_ch = child[nv];
			rnv = nv;
		}
	}

	if (mx_ch > n / 2) DFS2(rnv);
	else
	{
		for (int i = 1; i <= n; i++) cache[i] = 0;
		cache[v] = 1;

		for (int nv : graph[v])
		{
			if (par[nv] != v) continue;
			cc.emplace_back();
			DFS3(nv);
		}

		cc.emplace_back();
		return;
	}
}

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;
			child[i] = 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;

		DFS2(1);

		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();
				}
			}
		}

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