#include <bits/stdc++.h>
using namespace std;
const int MX = 500005;
int n, m, vis[MX], lvl[MX], p[MX], dis[MX], in[MX];
vector<int> gra[MX], adj[MX];
void clear() {
  for (int i = 1; i <= n; i++) {
    gra[i].clear();
    adj[i].clear();
    vis[i] = 0;
    in[i] = 0;
  }
}
void pre(int u) {
  vis[u] = 1;
  for (int v : gra[u])
    if (!vis[v]) {
      adj[u].push_back(v);
      adj[v].push_back(u);
      lvl[v] = lvl[u] + 1;
      pre(v);
    }
}
pair<int, int> bfs(int s) {
  for (int i = 1; i <= n; i++) p[i] = dis[i] = -1;
  queue<int> q;
  q.push(s);
  dis[s] = 1;
  int mx = 1, ind = s;
  while (q.size()) {
    int u = q.front();
    q.pop();
    mx = dis[u];
    ind = u;
    for (int v : adj[u])
      if (dis[v] == -1) {
        dis[v] = dis[u] + 1;
        p[v] = u;
        q.push(v);
      }
  }
  return {mx, ind};
}
void solve() {
  cin >> n >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    gra[u].push_back(v);
    gra[v].push_back(u);
  }
  lvl[1] = 1;
  pre(1);
  pair<int, int> x = bfs(bfs(1).second);
  if (x.first * 2 >= n) {
    cout << "PATH" << '\n';
    cout << (n + 1) / 2 << '\n';
    int u = x.second;
    for (int i = 0; i < (n + 1) / 2; i++) {
      cout << u << " ";
      u = p[u];
    }
    cout << '\n';
    clear();
    return;
  }
  cout << "PAIRING" << '\n';
  vector<pair<int, int> > v;
  for (int i = 1; i <= n; i++) {
    if (in[lvl[i]]) {
      v.emplace_back(i, in[lvl[i]]);
      in[lvl[i]] = 0;
    } else
      in[lvl[i]] = i;
  }
  cout << v.size() << '\n';
  for (pair<int, int> &p : v) cout << p.first << " " << p.second << '\n';
  clear();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
