#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
      int x, y;
      cin >> x >> y;
      --x;
      --y;
      g[x].push_back(y);
      g[y].push_back(x);
    }
    vector<bool> mark(n, false);
    vector<int> pv(n, -1);
    vector<int> dep(n, 0);
    vector<vector<int>> at(n);
    function<void(int)> Dfs = [&](int v) {
      mark[v] = 1;
      at[dep[v]].push_back(v);
      for (int to : g[v]) {
        if (!mark[to]) {
          pv[to] = v;
          dep[to] = dep[v] + 1;
          Dfs(to);
        }
      }
    };
    Dfs(0);
    int id = max_element(dep.begin(), dep.end()) - dep.begin();
    if (dep[id] + 1 >= (n + 1) / 2) {
      cout << "PATH" << '\n';
      cout << dep[id] + 1 << '\n';
      while (id != -1) {
        cout << id + 1 << " ";
        id = pv[id];
      }
      cout << '\n';
    } else {
      cout << "PAIRING" << '\n';
      vector<pair<int, int>> vec;
      for (int i = 0; i < n; i++) {
        int m = (int)at[i].size();
        for (int j = 0; j + 1 < m; j += 2) {
          vec.emplace_back(at[i][j], at[i][j + 1]);
        }
      }
      assert(2 * (int)vec.size() >= (n + 1) / 2);
      cout << (int)vec.size() << '\n';
      for (auto u : vec) {
        cout << u.first + 1 << " " << u.second + 1 << '\n';
      }
    }
  }
  return 0;
}
