    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn];
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

int find_(int u,int p){
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] >= n / 2 )
                return find_(v,u);
        }
    }
    return u;
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        int centroid = find_(1,1);

        int cnt = 0;
        for( auto v : t[centroid] ){
            dfs_2(v,centroid,++cnt);
        }
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    ii mark = {-1,0};
    for( auto v : t[u] ){
        if( v != p ){
            mark = max( mark , { subt[v] , v } );
        }
    }
    if( n - lv[u] - 1 < ( n + 1 ) / 2 )
    mark = {0,0};
    for( auto v : t[u] ){
        if( v != p && v != mark.s ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark.s ) return u;
    return find_(mark.s,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        int sum = 0;
        for(int i=1; i<=cnt; i++)
            sum += v[i].size();

        vector<int> vx;
        for(int i=1; i<=cnt; i++){
            for(int j=0; j<min((int)v[i].size(),sum-(int)v[i].size()); j++)
                vx.pb(v[i][j]);
        }
        if( vx.size() % 2 ) vx.pop_back();

        vector<ii> ans;
        for(int i=0; i<vx.size()/2; i++)
            ans.pb({vx[i],vx[i+vx.size()/2]});

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn];
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

int find_(int u,int p){
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] >= n / 2 )
                return find_(v,u);
        }
    }
    return u;
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        int centroid = find_(1,1);

        int cnt = 0;
        for( auto v : t[centroid] ){
            dfs_2(v,centroid,++cnt);
        }
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v]  >= n / 2 )
                mark = v;
        }
    }
    if( !mark ) return u;
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        for( auto v : t[centroid] ){
            dfs_2(v,centroid,++cnt);
        }
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] > 3 * n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] >= 2 * n / 3 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v]  > n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] > n / 4 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            //db(( n - lv[u] - subt[v] ))
            if( ( n - lv[u] - subt[v] ) * 2 < ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            if( ( n - lv[u] - subt[u] ) * 2 < ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            //db(( n - lv[u] - subt[v] ))
            if( ( n - lv[u] - subt[v] ) * 2 < ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn];
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            dfs_1(v,u);
            lv[v] = lv[u] + 1;
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

int find_(int u,int p){
    for( auto v : t[u] ){
        if( v != p ){
            if( subt[v] + lv[u] >= 3 * n / 4 )
                return find_(v,u);
        }
    }
    return u;
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        int centroid = find_(1,1);

        int cnt = 0;
        for( auto v : t[centroid] ){
            dfs_2(v,centroid,++cnt);
        }
        for( auto v : t[1] ){
            if( subt[v] <= n / 2 ){
                dfs_2(v,1,++cnt);
            }
        }

        priority_queue<ii> pq;
        for(int i=1; i<=cnt; i++){
            ii psh = {(int)v[i].size(),i};
            pq.push(psh);
        }

        vector<ii> ans;
        while( (int)ans.size() * 2 < ( 1 + n ) / 2 ){
            if( pq.size() <= 1 ){ cout<<ans.size()<<' '; cout << "BAD"; return 0; }
            ii aa = pq.top(); pq.pop();
            ii bb = pq.top(); pq.pop();

            ans.pb({v[aa.s].back(),v[bb.s].back()});
            v[aa.s].pop_back();
            v[bb.s].pop_back();

            if( aa.f - 1 > 0 ) pq.push({aa.f-1,aa.s});
            if( bb.f - 1 > 0 ) pq.push({bb.f-1,bb.s});
        }

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            //db(( n - lv[u] - subt[v] ))
            if( ( n - lv[u] - subt[v] ) * 2 < ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        vector<int> vx;
        for(int i=1; i<=cnt; i++){
            for( auto j : v[i] )
                vx.pb(j);
        }
        if( vx.size() % 2 ) vx.pop_back();

        vector<ii> ans;
        for(int i=0; i<vx.size()/2; i++)
            ans.pb({vx[i],vx[i+vx.size()/2]});

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


    /**   Created by: Humberto Yusta
          Codeforces User: humbertoyusta
          Country: Cuba
          Copyright��                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 1000010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return pwur * pwur % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int n, m, lv[maxn], subt[maxn], mk[maxn], parent[maxn], cnt;
vector<int> g[maxn], v[maxn], t[maxn], it[maxn];

void dfs_1(int u,int p){
    subt[u] = 1;
    for( auto v : g[u] ){
        if( v != p && !subt[v] ){
            lv[v] = lv[u] + 1;
            dfs_1(v,u);
            subt[u] += subt[v];
            t[u].pb(v);
            it[v].pb(u);
        }
    }
}

void dfs_2(int u,int p,int c){
    v[c].pb(u);
    for( auto v : t[u] )
        if( v != p && subt[v] <= n / 2 )
            dfs_2(v,u,c);
}

int find_(int u,int p){
    int mark = 0;
    for( auto v : t[u] ){
        if( v != p ){
            //db(( n - lv[u] - subt[v] ))
            if( ( n - lv[u] - subt[v] ) * 2 < ( 1 + n ) / 2 )
                mark = v;
        }
    }
    for( auto v : t[u] ){
        if( v != p && v != mark ){
             dfs_2(v,u,++cnt);
        }
    }
    if( !mark ) return u;
    return find_(mark,u);
}

ii dfs_3(int u,int p){
    if( t[u].size() == 0 )
        return {lv[u],u};
    ii res = {-1,0};
    for( auto v : t[u] )
        res = max( res , dfs_3(v,u) );
    return res;
}

ii dfs_4(int u,int p,int dist){
    parent[u] = p;
    if( it[u].size() + t[u].size() == 1 && u != p )
        return {dist,u};
    ii res = {-1,0};
    for( auto v : t[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    for( auto v : it[u] )
        if( v != p )
            res = max( res , dfs_4(v,u,dist+1) );
    return res;
}

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);

    int tc;
    cin >> tc;
    while( tc-- ){

        cin >> n >> m;

        for(int i=1; i<=n; i++){
            g[i].clear();
            v[i].clear();
            t[i].clear();
            it[i].clear();
            lv[i] = 0;
            subt[i] = 0;
            parent[i] = 0;
        }

        for(int i=1; i<=m; i++){
            int u, v;
            cin >> u >> v;
            g[u].pb(v);
            g[v].pb(u);
        }

        if( n == 2 ){
            cout << "PATH\n";
            cout << 2 << '\n';
            cout << 1 << ' ' << 2 << '\n';
            continue;
        }

        lv[1] = 1;
        dfs_1(1,1);

        //db(n)db(m)

        ii u1 = dfs_3(1,1);
        ii u2 = dfs_4(u1.s,u1.s,1);
        if( u2.f >= ( 1 + n ) / 2 ){
            cout << "PATH\n";
            cout << u2.f << '\n';
            int pp = u2.s;
            while( u2.s != u1.s ){
                cout << u2.s << ' ';
                u2.s = parent[u2.s];
            }
            cout << u2.s << '\n';
            continue;
        }

        cnt = 0;

        int centroid = find_(1,1);

        //for( auto v : t[centroid] ){
        //    dfs_2(v,centroid,++cnt);
        //}
        //for( auto v : t[1] ){
        //    if( subt[v] <= n / 2 ){
        //        dfs_2(v,1,++cnt);
        //    }
        //}

        int sum = 0;
        for(int i=1; i<=cnt; i++)
            sum += v[i].size();

        vector<int> vx;
        for(int i=1; i<=cnt; i++){
            for(int j=0; j<min((int)v[i].size(),sum-(int)v[i].size()); j++)
                vx.pb(v[i][j]);
        }
        if( vx.size() % 2 ) vx.pop_back();

        vector<ii> ans;
        for(int i=0; i<vx.size()/2; i++)
            ans.pb({vx[i],vx[i+vx.size()/2]});

        cout << "PAIRING\n";
        cout << ans.size() << '\n';
        for( auto pk : ans ){
            cout << pk.f << ' ' << pk.s << '\n';
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;

int depth[N], par[N];
vector<int> level[N];
vector<int> v[N];
bool vis[N];

void dfs(int s, int p, int lvl = 0){
   if (vis[s]){
      return ;
   }
   vis[s] = 1;
   level[lvl].push_back(s);
   depth[s] = lvl;
   par[s] = p;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, lvl+1);
      }
   }
}

void solve(){
   cin>>n>>m;

   for (int i = 0; i <= n; ++i)
   {
      level[i].clear();
      v[i].clear();
      par[i] = 0;
      vis[i] = 0;
      depth[i] = 0;
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      swap(x, y);
      v[x].push_back(y);
   }

   dfs(1, 0);

   int limit = (n + 1)/2;

   int mx = -1;
   for (int i = 1; i <= n; ++i)
   {
      if (depth[i] >= limit){
         mx = i;
         break;
      }
   }

   if (mx != -1){
      vector<int> ans;
      while(mx){
         ans.push_back(mx);
         mx = par[mx];
      }

      cout<<"PATH"<<endl;
      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans)
         cout<<it<<" ";
      cout<<endl;
   }

   else{

      cout<<"PAIRING"<<endl;

      vector<array<int, 2>> ans;
      for (int i = 0; i <= n; ++i)
      {
         for (int j = 0; j+1 < (int)(level[i].size()); j += 2)
         {
            ans.push_back({level[i][j], level[i][j+1]});
         }
      }

      // assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto &it: ans)
      // for (int i = 0; i < limit; ++i)
      {
         cout<<it[0]<<" "<<it[1]<<endl;
      }
   }

}

int32_t main(){_

   int t = 1;
   cin >> t;

   while(t--){
     solve();
   }

   return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;

int depth[N], par[N];
vector<int> level[N];
vector<int> v[N];
bool vis[N];

void dfs(int s, int p, int lvl = 0){
   if (vis[s]){
      return ;
   }
   vis[s] = 1;
   level[lvl].push_back(s);
   depth[s] = lvl;
   par[s] = p;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, lvl+1);
      }
   }
}

void solve(){
   cin>>n>>m;

   for (int i = 0; i <= n; ++i)
   {
      level[i].clear();
      v[i].clear();
      par[i] = 0;
      vis[i] = 0;
      depth[i] = 0;
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      swap(x, y);
      v[x].push_back(y);
   }

   dfs(1, 0);

   int limit = (n + 1)/2;

   int mx = -1;
   for (int i = 1; i <= n; ++i)
   {
      if (depth[i] >= limit){
         mx = i;
         break;
      }
   }

   if (mx != -1){
      vector<int> ans;
      while(mx){
         ans.push_back(mx);
         mx = par[mx];
      }

      cout<<"PATH"<<endl;
      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans)
         cout<<it<<" ";
      cout<<endl;
   }

   else{

      cout<<"PAIRING"<<endl;

      vector<array<int, 2>> ans;
      for (int i = 0; i <= n; ++i)
      {
         for (int j = 0; j+1 < (int)(level[i].size()); ++j)
         {
            ans.push_back({level[i][j], level[i][j+1]});
         }
      }

      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans){
         cout<<it[0]<<" "<<it[1]<<endl;
      }
   }

}

int32_t main(){_

   int t = 1;
   cin >> t;

   while(t--){
     solve();
   }

   return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;

int depth[N], par[N];
vector<int> level[N];
vector<int> v[N];
bool vis[N];

void dfs(int s, int p, int lvl = 0){
   if (vis[s]){
      return ;
   }
   vis[s] = 1;
   level[lvl].push_back(s);
   depth[s] = lvl;
   par[s] = p;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, lvl+1);
      }
   }
}

void solve(){
   cin>>n>>m;

   for (int i = 0; i <= n; ++i)
   {
      level[i].clear();
      v[i].clear();
      par[i] = 0;
      vis[i] = 0;
      depth[i] = 0;
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      swap(x, y);
      v[x].push_back(y);
   }

   dfs(1, 0);

   int limit = (n + 1)/2;

   int mx = -1;
   for (int i = 1; i <= n; ++i)
   {
      if (depth[i] >= limit){
         mx = i;
         break;
      }
   }

   if (mx != -1){
      vector<int> ans;
      while(mx){
         ans.push_back(mx);
         mx = par[mx];
      }

      cout<<"PATH"<<endl;
      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans)
         cout<<it<<" ";
      cout<<endl;
   }

   else{

      cout<<"PAIRING"<<endl;

      vector<array<int, 2>> ans;
      for (int i = 0; i <= n; ++i)
      {
         for (int j = 0; j+1 < (int)(level[i].size()); j += 2)
         {
            ans.push_back({level[i][j], level[i][j+1]});
         }
      }

      // assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto &it: ans)
      // for (int i = 0; i < limit; ++i)
      {
         cout<<it[0]<<" "<<it[1]<<endl;
      }
   }

}

int32_t main(){_

   int t = 1;
   cin >> t;

   while(t--){
     solve();
   }

   return 0;
}


#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, m;

int depth[N], par[N];
vector<int> level[N];
vector<int> v[N];
bool vis[N];

void dfs(int s, int p, int lvl = 0){
   if (vis[s]){
      return ;
   }
   vis[s] = 1;
   level[lvl].push_back(s);
   depth[s] = lvl;
   par[s] = p;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, lvl+1);
      }
   }
}

void solve(){
   cin>>n>>m;

   for (int i = 0; i <= n; ++i)
   {
      level[i].clear();
      v[i].clear();
      par[i] = 0;
      vis[i] = 0;
      depth[i] = 0;
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y;
      cin >> x >> y;
      v[x].push_back(y);
      swap(x, y);
      v[x].push_back(y);
   }

   dfs(1, 0);

   int limit = (n + 1)/2;

   int mx = -1;
   for (int i = 1; i <= n; ++i)
   {
      if (depth[i] >= limit){
         mx = i;
         break;
      }
   }

   if (mx != -1){
      vector<int> ans;
      while(mx){
         ans.push_back(mx);
         mx = par[mx];
      }

      cout<<"PATH"<<endl;
      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans)
         cout<<it<<" ";
   }

   else{

      cout<<"PAIRING"<<endl;

      vector<array<int, 2>> ans;
      for (int i = 0; i <= n; ++i)
      {
         for (int j = 0; j+1 < (int)(level[i].size()); ++j)
         {
            ans.push_back({level[i][j], level[i][j+1]});
         }
      }

      assert((int)(ans.size()) >= limit);
      cout<<(int)(ans.size())<<endl;
      for(auto it: ans){
         cout<<it[0]<<" "<<it[1]<<endl;
      }
   }

}

int32_t main(){_

   int t = 1;
   cin >> t;

   while(t--){
     solve();
   }

   return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))

constexpr int N = 5e5+9;
constexpr int M = 1e9+7;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int t, n, m;
vector<int> g[N];
int d[N], vis[N], fa[N];
vector<int> lvl[N];

void dfs(int u, int p) {
    vis[u] = 1;
    fa[u] = p;
    d[u] = d[p] + 1;
    lvl[d[u]].emplace_back(u);
    for (int v: g[u]) {
        if (vis[v]) continue;
        dfs(v, u);
    }
}

// 注意N范围
// 注意除0
// 注意不要超int范围
// 注意分支全部覆盖
// 注意变量不要写错
// 注意清空上个case的影响
// 注意嵌套不要错
// 先复核，后提交

signed main() {
    fastio;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            vis[i] = d[i] = fa[i] = 0;
            lvl[i].clear();
        }
        for (int i = 1; i <= m; i++) {
            int u, v;
            cin >> u >> v;
            g[u].emplace_back(v);
            g[v].emplace_back(u);
        }
        dfs(1, 0);
        int maxi = *max_element(d+1, d+1+n);
        if (d[maxi] >= (n+1) / 2) {
            cout << "PATH" << endl;
            while (maxi) {
                cout << maxi << " ";
                maxi = fa[maxi];
            }
            cout << endl;
        } else {
            cout << "PAIRING" << endl;
            vector<pii> ans;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j+2 <= SZ(lvl[i]); j += 2)
                    ans.emplace_back(lvl[i][j], lvl[i][j+1]);
            }
            cout << SZ(ans) << endl;
            for (auto& p: ans) cout << p.fi << " " << p.se << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))

constexpr int N = 5e5+9;
constexpr int M = 1e9+7;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int t, n, m;
vector<int> g[N];
int d[N], vis[N], fa[N];
vector<int> lvl[N];

void dfs(int u, int p) {
    vis[u] = 1;
    fa[u] = p;
    d[u] = d[p] + 1;
    lvl[d[u]].emplace_back(u);
    for (int v: g[u]) {
        if (vis[v]) continue;
        dfs(v, u);
    }
}

// 注意N范围
// 注意除0
// 注意不要超int范围
// 注意分支全部覆盖
// 注意变量不要写错
// 注意清空上个case的影响
// 注意嵌套不要错
// 先复核，后提交

signed main() {
    fastio;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            vis[i] = d[i] = fa[i] = 0;
            lvl[i].clear();
            g[i].clear();
        }
        for (int i = 1; i <= m; i++) {
            int u, v;
            cin >> u >> v;
            g[u].emplace_back(v);
            g[v].emplace_back(u);
        }
        dfs(1, 0);
        int maxi = *max_element(d+1, d+1+n);
        if (d[maxi] >= (n+1) / 2) {
            cout << "PATH" << endl;
            while (maxi) {
                cout << maxi << " ";
                maxi = fa[maxi];
            }
            cout << endl;
        } else {
            cout << "PAIRING" << endl;
            vector<pii> ans;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j+2 <= SZ(lvl[i]); j += 2)
                    ans.emplace_back(lvl[i][j], lvl[i][j+1]);
            }
            cout << SZ(ans) << endl;
            for (auto& p: ans) cout << p.fi << " " << p.se << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))

constexpr int N = 5e5+9;
constexpr int M = 1e9+7;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int t, n, m;
vector<int> g[N];
int d[N], vis[N], fa[N];
vector<int> lvl[N];

void dfs(int u, int p) {
    vis[u] = 1;
    fa[u] = p;
    d[u] = d[p] + 1;
    lvl[d[u]].emplace_back(u);
    for (int v: g[u]) {
        if (vis[v]) continue;
        dfs(v, u);
    }
}

// 注意N范围
// 注意除0
// 注意不要超int范围
// 注意分支全部覆盖
// 注意变量不要写错
// 注意清空上个case的影响
// 注意嵌套不要错
// 检查输入输出格式
// 先复核，后提交

signed main() {
    fastio;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            vis[i] = d[i] = fa[i] = 0;
            lvl[i].clear();
            g[i].clear();
        }
        for (int i = 1; i <= m; i++) {
            int u, v;
            cin >> u >> v;
            g[u].emplace_back(v);
            g[v].emplace_back(u);
        }
        dfs(1, 0);
        int maxi = max_element(d+1, d+1+n) - d;
        if (d[maxi] >= (n+1) / 2) {
            cout << "PATH" << endl;
            vector<int> ans;
            while (maxi) {
                ans.emplace_back(maxi);
                maxi = fa[maxi];
            }
            cout << SZ(ans) << endl;
            for (int j: ans) cout << j << " ";
            cout << endl;
        } else {
            cout << "PAIRING" << endl;
            vector<pii> ans;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j+2 <= SZ(lvl[i]); j += 2)
                    ans.emplace_back(lvl[i][j], lvl[i][j+1]);
            }
            cout << SZ(ans) << endl;
            for (auto& p: ans) cout << p.fi << " " << p.se << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define LL long long
#define int long long
#define fi first
#define se second
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define SZ(x) ((int)(x.size()))

constexpr int N = 5e5+9;
constexpr int M = 1e9+7;
constexpr int INF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF2 = 0xcfcfcfcfcfcfcfcf;

int t, n, m;
vector<int> g[N];
int d[N], vis[N], fa[N];
vector<int> lvl[N];

void dfs(int u, int p) {
    vis[u] = 1;
    fa[u] = p;
    d[u] = d[p] + 1;
    lvl[d[u]].emplace_back(u);
    for (int v: g[u]) {
        if (vis[v]) continue;
        dfs(v, u);
    }
}

// 注意N范围
// 注意除0
// 注意不要超int范围
// 注意分支全部覆盖
// 注意变量不要写错
// 注意清空上个case的影响
// 注意嵌套不要错
// 先复核，后提交

signed main() {
    fastio;
    cin >> t;
    while (t--) {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            vis[i] = d[i] = fa[i] = 0;
            lvl[i].clear();
            g[i].clear();
        }
        for (int i = 1; i <= m; i++) {
            int u, v;
            cin >> u >> v;
            g[u].emplace_back(v);
            g[v].emplace_back(u);
        }
        dfs(1, 0);
        int maxi = *max_element(d+1, d+1+n);
        if (d[maxi] >= (n+1) / 2) {
            cout << "PATH" << endl;
            vector<int> ans;
            while (maxi) {
                ans.emplace_back(maxi);
                maxi = fa[maxi];
            }
            cout << SZ(ans) << endl;
            for (int j: ans) cout << j << " ";
            cout << endl;
        } else {
            cout << "PAIRING" << endl;
            vector<pii> ans;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j+2 <= SZ(lvl[i]); j += 2)
                    ans.emplace_back(lvl[i][j], lvl[i][j+1]);
            }
            cout << SZ(ans) << endl;
            for (auto& p: ans) cout << p.fi << " " << p.se << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*

██╗    ██╗██████╗ ██╗████████╗████████╗███████╗███╗   ██╗    ██████╗ ██╗   ██╗
██║    ██║██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗  ██║    ██╔══██╗╚██╗ ██╔╝
██║ █╗ ██║██████╔╝██║   ██║      ██║   █████╗  ██╔██╗ ██║    ██████╔╝ ╚████╔╝
██║███╗██║██╔══██╗██║   ██║      ██║   ██╔══╝  ██║╚██╗██║    ██╔══██╗  ╚██╔╝
╚███╔███╔╝██║  ██║██║   ██║      ██║   ███████╗██║ ╚████║    ██████╔╝   ██║
 ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝   ╚═╝      ╚═╝   ╚══════╝╚═╝  ╚═══╝    ╚═════╝    ╚═╝

     ███╗   ███╗   ██╗██████╗ ██████╗  █████╗ ██╗  ██╗██╗███╗   ███╗
     ████╗ ████║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██║████╗ ████║
     ██╔████╔██║   ██║██████╔╝██████╔╝███████║███████║██║██╔████╔██║
     ██║╚██╔╝██║   ██║██╔══██╗██╔══██╗██╔══██║██╔══██║██║██║╚██╔╝██║
     ██║ ╚═╝ ██║██╗██║██████╔╝██║  ██║██║  ██║██║  ██║██║██║ ╚═╝ ██║
     ╚═╝     ╚═╝╚═╝╚═╝╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝     ╚═╝
*/
#define speed  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(n) for(int i=0;i<n;i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define E "\n"
#define all(e) e.begin(),e.end()
#define F first
#define S second
#define rad(x) ((x*pi)/(ld)(180))
#define perc(x) fixed<<setprecision(x)
typedef long long int ll; typedef unsigned long long ull; typedef long double ld;typedef complex<ld> point; typedef tuple<double,double,double> line;
ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);};
const int N = 2e7+1;
priority_queue<int, vector<int> , greater<int> > pq;
ll n,x,a1=1,a2=1e6, p1,p2,arr[100002];

int srl,sru;
void low(int s,int e,int a)
{
    if(e<s)return;
    int m=s+((e-s)/2);
    if(arr[m]>=a)srl=m,e=m-1;
    else s=m+1;
    low(s,e,a);
}

void high(int s,int e,int a)
{
    if(e<s)return;
    int m=s+((e-s)/2);
    if(arr[m]<=a)sru=m,s=m+1;
    else e=m-1;
    high(s,e,a);
}

int main(){speed;
cin>>n;
FOR(n)
{
    cin>>arr[i];
}
low(0,n,500000),high(0,n,500000);
//cout<<sru << ' '<< srl<<E;
if(arr[srl]>=500000)
cout<< min(499999ll,max(arr[sru]-1,1000000-arr[srl]));
else cout<<arr[sru-1]-1;
return 0;}


#include<bits/stdc++.h>
using namespace std;
/*

██╗    ██╗██████╗ ██╗████████╗████████╗███████╗███╗   ██╗    ██████╗ ██╗   ██╗
██║    ██║██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗  ██║    ██╔══██╗╚██╗ ██╔╝
██║ █╗ ██║██████╔╝██║   ██║      ██║   █████╗  ██╔██╗ ██║    ██████╔╝ ╚████╔╝
██║███╗██║██╔══██╗██║   ██║      ██║   ██╔══╝  ██║╚██╗██║    ██╔══██╗  ╚██╔╝
╚███╔███╔╝██║  ██║██║   ██║      ██║   ███████╗██║ ╚████║    ██████╔╝   ██║
 ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝   ╚═╝      ╚═╝   ╚══════╝╚═╝  ╚═══╝    ╚═════╝    ╚═╝

     ███╗   ███╗   ██╗██████╗ ██████╗  █████╗ ██╗  ██╗██╗███╗   ███╗
     ████╗ ████║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██║████╗ ████║
     ██╔████╔██║   ██║██████╔╝██████╔╝███████║███████║██║██╔████╔██║
     ██║╚██╔╝██║   ██║██╔══██╗██╔══██╗██╔══██║██╔══██║██║██║╚██╔╝██║
     ██║ ╚═╝ ██║██╗██║██████╔╝██║  ██║██║  ██║██║  ██║██║██║ ╚═╝ ██║
     ╚═╝     ╚═╝╚═╝╚═╝╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝     ╚═╝
*/
#define speed  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(n) for(int i=0;i<n;i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define E "\n"
#define all(e) e.begin(),e.end()
#define F first
#define S second
#define rad(x) ((x*pi)/(ld)(180))
#define perc(x) fixed<<setprecision(x)
typedef long long int ll; typedef unsigned long long ull; typedef long double ld;typedef complex<ld> point; typedef tuple<double,double,double> line;
ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);};
const int N = 2e7+1;
priority_queue<int, vector<int> , greater<int> > pq;
ll n,x,a1=1,a2=1e6, p1,p2;

int main(){speed;
cin>>n;
FOR(n)
{
    cin>>x;
    int c = abs(x-a1), c2 = abs(a2-x);
    if(c + p1 < p2 + c2)a1=x,p1+=c;
    else a2=x,p2+=c2;

}

cout<<max(p1,p2);
return 0;}


#include <bits/stdc++.h>

using namespace std;
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long int ll;

int main(){
    speed;
int n;
cin>>n;
int p1=1,p2=1000000;
int ans=0;
for(int i=0;i<n;i++)
{
    int x;
cin>>x;
if(x-1<(1000000-x)){p1=max(x,p1);}
else if(x-1>=(1000000-x)){p2=min(x,p2);}
}
p1=p1-1;
p2=1000000-p2;
ans=max(p1,p2);
cout<<ans<<endl;
    return 0;
}
//if(){}