#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 200;
vector<int> g[N], dep[N];
int par[N], d[N];
bool vis[N];
void dfs(int v, int p) {
  d[v] = d[p] + 1;
  vis[v] = 1;
  dep[d[v]].push_back(v);
  par[v] = p;
  for (int x : g[v]) {
    if (!vis[x]) dfs(x, v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i <= n; i++) g[i].clear(), vis[i] = 0, dep[i].clear();
    d[0] = 0;
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      u--;
      v--;
      g[v].push_back(u);
      g[u].push_back(v);
    }
    dfs(0, 0);
    if (!dep[n % 2 + n / 2].empty()) {
      int v = dep[n % 2 + n / 2][0];
      cout << "PATH"
           << "\n"
           << n / 2 + n % 2 << "\n";
      while (v != 0) {
        cout << v + 1 << " ", v = par[v];
      }
      cout << 1 << "\n";
    } else {
      cout << "PAIRING"
           << "\n";
      int cnt = 0;
      vector<pair<int, int>> b;
      for (int i = 0; cnt < n / 2 + n % 2; i++) {
        for (int j = 1; j < dep[i].size() && cnt < n / 2 + n % 2; j += 2)
          b.push_back({dep[i][j] + 1, dep[i][j - 1] + 1}), cnt += 2;
      }
      cout << b.size() << "\n";
      for (auto [k, l] : b) cout << k << " " << l << "\n";
    }
  }
}
