#include <bits/stdc++.h>
using namespace std;
int n, m, half;
vector<int> E[500000 + 5];
vector<int> stk;
vector<int> layer[500000 + 5];
int deep[500000 + 5];
bool vis[500000 + 5];
bool isPath = 0;
void dfs(int x, int fa) {
  vis[x] = 1;
  deep[x] = deep[fa] + 1;
  stk.push_back(x);
  layer[deep[x]].push_back(x);
  if (deep[x] >= half && !isPath) {
    isPath = 1;
    printf("PATH\n%d\n", (int)stk.size());
    for (int x : stk) printf("%d ", x);
    printf("\n");
  }
  for (int y : E[x])
    if (!vis[y]) dfs(y, x);
  stk.pop_back();
}
void ini() {
  stk.clear();
  for (int i = 1; i <= n; i++) {
    E[i].clear();
    layer[i].clear();
    deep[i] = 0;
    vis[i] = 0;
  }
  isPath = 0;
}
int main() {
  int t, u, v;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &m);
    ini();
    half = (n % 2 == 0 ? n / 2 : n / 2 + 1);
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      E[u].push_back(v);
      E[v].push_back(u);
    }
    dfs(1, 0);
    if (!isPath) {
      vector<pair<int, int> > ans;
      for (int i = 1; i <= n; i++) {
        for (int j = 0; j < (int)layer[i].size(); j += 2) {
          if (j + 1 < (int)layer[i].size())
            ans.push_back(make_pair(layer[i][j], layer[i][j + 1]));
        }
      }
      printf("PAIRING\n%d\n", ans.size());
      for (auto p : ans) printf("%d %d\n", p.first, p.second);
    }
  }
}
