#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long N = 100005;
const long long M = 1000000007;
const long long INF = 1e12;
long long pow1(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % M;
    }
    a = (a * a) % M;
    b >>= 1;
  }
  return res % M;
}
vector<vector<long long> > adj;
vector<long long> depth, vis, parent;
void dfs(long long src, long long par, long long dpth) {
  vis[src] = 1;
  depth[src] = dpth;
  parent[src] = par;
  for (auto it : adj[src]) {
    if (vis[it] == 0) {
      dfs(it, src, dpth + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  cin >> T;
  while (T--) {
    long long n, m;
    cin >> n >> m;
    adj = vector<vector<long long> >(n + 1);
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    parent = depth = vis = vector<long long>(n + 1, 0);
    dfs(1, 0, 1);
    long long node = -1;
    for (int i = 1; i < n + 1; i++) {
      if (depth[i] > (n + 1) / 2) {
        node = i;
      }
    }
    if (node != -1) {
      vector<long long> tmp;
      while (node != 0) {
        tmp.push_back(node);
        node = parent[node];
      }
      cout << "PATH"
           << "\n";
      cout << tmp.size() << "\n";
      for (auto i : tmp) cout << i << " ";
      cout << "\n";
      ;
    } else {
      vector<pair<long long, long long> > tmp1;
      for (int i = 1; i <= n; i++) tmp1.push_back({depth[i], i});
      sort(tmp1.begin(), tmp1.end());
      vector<pair<long long, long long> > tmp;
      for (long long i = 0; i < tmp1.size() - 1; i++) {
        if (tmp1[i].first == tmp1[i + 1].first) {
          tmp.push_back({tmp1[i].second, tmp1[i + 1].second});
          i++;
        }
      }
      cout << "PAIRING"
           << "\n";
      cout << tmp.size() << "\n";
      for (auto it : tmp) cout << it.first << " " << it.second << "\n";
    }
  }
}
