#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long t, n, m, d[maxn], par[maxn];
bool vis[maxn];
vector<long long> vec[maxn], g[maxn];
vector<pair<long long, long long> > ans;
void dfs(long long v) {
  vis[v] = 1;
  vec[d[v]].push_back(v);
  for (long long u : g[v]) {
    if (!vis[u]) {
      d[u] = d[v] + 1;
      par[u] = v;
      dfs(u);
    }
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    for (long long i = 0; i <= n; i++) {
      vis[i] = 0;
      g[i].clear();
      vec[i].clear();
    }
    cin >> n >> m;
    for (long long i = 0; i < m; i++) {
      long long v, u;
      cin >> v >> u;
      g[v].push_back(u);
      g[u].push_back(v);
    }
    dfs(1);
    if (vec[(n - 1) / 2].empty()) {
      cout << "PAIRING\n";
      ans.clear();
      for (long long i = 0; i < n; i++) {
        for (long long j = 0; j + 1 < (long long)vec[i].size(); j += 2) {
          ans.push_back(make_pair(vec[i][j], vec[i][j + 1]));
        }
      }
      cout << ans.size() << '\n';
      for (pair<long long, long long> i : ans) {
        cout << i.first << " " << i.second << '\n';
      }
    } else {
      long long v = vec[(n - 1) / 2][0];
      cout << "PATH\n";
      cout << (n + 1) / 2 << '\n';
      while (v) {
        cout << v << " ";
        v = par[v];
      }
      cout << '\n';
    }
  }
  return 0;
}
