#include <bits/stdc++.h>
using namespace std;
vector<int> adj[500001], all[500001];
bool vis[500001], output;
int par[500001], dep[500001], n, m, pairs;
void dfs(int u) {
  if (output) return;
  vis[u] = 1;
  pairs -= all[dep[u]].size() / 2;
  all[dep[u]].push_back(u);
  pairs += all[dep[u]].size() / 2;
  if (dep[u] >= (n + 1) / 2) {
    cout << "PATH" << endl;
    cout << dep[u] << endl;
    for (int i = dep[u]; i >= 1; i--) {
      cout << u << " ";
      u = par[u];
    }
    cout << endl;
    output = 1;
    return;
  }
  for (int v : adj[u]) {
    if (!vis[v]) {
      dep[v] = dep[u] + 1;
      par[v] = u;
      dfs(v);
    }
  }
}
void solve() {
  output = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    adj[i].clear();
    all[i].clear();
    vis[i] = 0;
    par[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  pairs = 0;
  dep[1] = 1;
  dfs(1);
  if (output) return;
  cout << "PAIRING" << endl;
  cout << pairs << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < all[i].size(); j += 2) {
      if (all[i].size() >= j + 2)
        cout << all[i][j] << " " << all[i][j + 1] << endl;
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
