#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx")
using namespace std;
int n, m;
vector<vector<int> > graph;
vector<vector<int> > depth;
vector<bool> used;
vector<int> st;
bool dfs(int v, int h) {
  st.push_back(v);
  used[v] = true;
  depth[h].push_back(v);
  if (2 * h >= n) {
    return true;
  }
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i];
    if (!used[to]) {
      if (dfs(to, h + 1)) {
        return true;
      }
    }
  }
  st.pop_back();
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    graph.clear();
    st.clear();
    used.clear();
    depth.clear();
    graph.resize(n + 1);
    used.resize(n + 1, false);
    depth.resize(n + 1);
    for (int i = 1; i <= m; i++) {
      int u, v;
      cin >> u >> v;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    if (dfs(1, 1)) {
      cout << "PATH" << endl;
      cout << st.size() << endl;
      for (int i = 0; i < st.size(); i++) {
        cout << st[i] << " ";
      }
      cout << endl;
    } else {
      cout << "PAIRING" << endl;
      vector<pair<int, int> > ans;
      for (int i = 2; i <= n / 2; i++) {
        for (int j = 0; j < (int)depth[i].size() - 1; j += 2) {
          ans.push_back({depth[i][j], depth[i][j + 1]});
        }
      }
      cout << ans.size() << endl;
      for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << " " << ans[i].second << endl;
      }
    }
  }
  return 0;
}
