#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long double PI = acos(-1);
const long long N = 5e5 + 1;
void test_case() {
  long long n, m;
  cin >> n >> m;
  vector<long long> v[n + 1];
  vector<long long> dis(n + 1, 0), par(n + 1, 0);
  vector<bool> vis(n + 1, 0);
  long long mx = 0;
  for (int i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  function<void(long long, long long)> dfs = [&](long long s, long long depth) {
    vis[s] = 1;
    dis[s] = depth;
    mx = max(mx, depth);
    for (auto u : v[s]) {
      if (!vis[u]) {
        par[u] = s;
        dfs(u, depth + 1);
      }
    }
  };
  dfs(1, 1);
  if (mx >= (n + 1) / 2) {
    cout << "PATH\n";
    cout << mx << '\n';
    long long curr;
    for (int i = 1; i <= n; i++) {
      if (dis[i] == mx) {
        curr = i;
        break;
      }
    }
    while (curr != 0) {
      cout << curr << ' ';
      curr = par[curr];
    }
    cout << '\n';
    return;
  }
  cout << "PAIRING\n";
  vector<long long> pp[mx + 1];
  for (int i = 1; i <= n; i++) pp[dis[i]].push_back(i);
  vector<pair<long long, long long>> res;
  for (int i = 1; i <= mx; i++) {
    for (int j = 1; j < pp[i].size(); j += 2)
      res.push_back({pp[i][j], pp[i][j - 1]});
  }
  cout << res.size() << "\n";
  for (auto u : res) cout << u.first << ' ' << u.second << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  cin >> tc;
  while (tc--) test_case();
  return 0;
}
