#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, F = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') F = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * F;
}
int add(int a, int b) {
  return (a + b >= 998244353) ? a + b - 998244353 : a + b;
}
int dec(int a, int b) { return (a - b < 0) ? a - b + 998244353 : a - b; }
int mul(int a, int b) { return (1LL * a * b) % 998244353; }
int fst_pow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a), b >>= 1;
  }
  return res;
}
int T, n, m, fa[500000 + 5], dep[500000 + 5];
vector<int> G[500000 + 5], P[500000 + 5];
int nd, mxd, cnt;
pair<int, int> ans[500000 + 5];
void dfs(int x) {
  dep[x] = dep[fa[x]] + 1, P[dep[x]].push_back(x);
  if (dep[x] > mxd) mxd = dep[x], nd = x;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (!dep[v]) fa[v] = x, dfs(v);
  }
}
int main() {
  T = read();
  while (T--) {
    n = read(), m = read(), cnt = nd = mxd = 0;
    for (int i = 1; i <= n; i++) dep[i] = 0, G[i].clear(), P[i].clear();
    for (int i = 1; i <= m; i++) {
      int u = read(), v = read();
      G[u].push_back(v);
      G[v].push_back(u);
    }
    dfs(1);
    for (int i = 1; i <= mxd; i++)
      for (int j = 1; j < P[i].size(); j += 2)
        ans[++cnt] = pair<int, int>(P[i][j - 1], P[i][j]);
    if ((cnt << 1) >= ((n + 1) >> 1)) {
      printf("PAIRING\n%d\n", cnt);
      for (int i = 1; i <= cnt; i++)
        printf("%d %d\n", ans[i].first, ans[i].second);
    } else {
      cnt = 0;
      while (nd) ans[++cnt] = pair<int, int>(nd, 0), nd = fa[nd];
      printf("PATH\n%d\n", cnt);
      for (int i = 1; i <= cnt; i++)
        printf("%d%c", ans[i].first, (i == cnt) ? '\n' : ' ');
    }
  }
}
