#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const long long maxn = (long long)1e6 + 5;
const long long mod = 998244353;
const long long inf = 0x3f3f3f3f;
long long T = 1;
vector<long long> v[maxn], vec[maxn];
long long dep[maxn], pre[maxn];
long long maxx;
void dfs(long long now) {
  maxx = max(maxx, dep[now]);
  vec[dep[now]].push_back(now);
  for (auto &to : v[now]) {
    if (dep[to]) continue;
    pre[to] = now;
    dep[to] = dep[now] + 1;
    dfs(to);
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  maxx = 1;
  for (long long i = 1; i <= n; ++i) v[i].clear(), vec[i].clear(), dep[i] = 0;
  for (long long i = 1; i <= m; ++i) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dep[1] = 1;
  dfs(1);
  if (maxx > (n + 1) / 2) {
    cout << "PATH\n";
    stack<long long> s;
    long long now = vec[maxx][0];
    while (now) {
      s.push(now);
      now = pre[now];
    }
    cout << s.size() << '\n';
    while (!s.empty()) {
      cout << s.top() << ' ';
      s.pop();
    }
    cout << '\n';
    return;
  }
  cout << "PAIRING\n";
  long long ans = 0;
  for (long long i = 1; i <= maxx; ++i) {
    ans += vec[i].size() / 2;
  }
  cout << ans << '\n';
  for (long long i = 1; i <= maxx; ++i) {
    for (long long j = 0; j + 1 < vec[i].size(); j += 2) {
      cout << vec[i][j] << ' ' << vec[i][j + 1] << '\n';
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> T;
  while (T--) solve();
  return 0;
}
