#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> d, g;
vector<long long> used;
vector<long long> path;
void dfs(long long v, long long d1) {
  used[v] = 1;
  d[d1].push_back(v);
  for (auto u : g[v])
    if (!used[u]) dfs(u, d1 + 1);
}
void get_ans(long long v) {
  used[v] = 0;
  if (path.size() * 2 < g.size()) path.push_back(v);
  for (auto u : g[v])
    if (used[u]) get_ans(u);
  if (path.size() * 2 < g.size()) path.pop_back();
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    d.assign(n + 1, vector<long long>(0));
    g.assign(n, vector<long long>(0));
    used.assign(n, 0);
    path.clear();
    for (long long i = 0; i < m; ++i) {
      long long v, u;
      cin >> v >> u;
      v--, u--;
      g[u].push_back(v), g[v].push_back(u);
    }
    for (long long i = 0; i < n; ++i)
      if (!used[i]) dfs(i, 0);
    long long k = 0;
    for (long long i = 0; i < n + 1; ++i)
      if (d[i].size() > 0) k = i;
    if (k * 2 >= n) {
      cout << "PATH\n";
      for (long long i = 0; i < n; ++i)
        if (used[i]) get_ans(i);
      cout << path.size() << '\n';
      for (long long i = 0; i < path.size(); ++i) cout << path[i] + 1 << ' ';
      cout << '\n';
    } else {
      vector<pair<long long, long long>> ans;
      for (long long i = 0; i < n + 1; ++i) {
        for (long long j = 0; j + 1 < d[i].size(); j += 2)
          ans.push_back({d[i][j], d[i][j + 1]});
      }
      cout << "PAIRING\n";
      cout << ans.size() << '\n';
      for (long long i = 0; i < ans.size(); ++i)
        cout << ans[i].first + 1 << ' ' << ans[i].second + 1 << '\n';
    }
  }
  return 0;
}
