#include <bits/stdc++.h>
using namespace std;
const int N = 80000 + 30;
char a[N], b[N];
int main()
{
    int t, n, x, y;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d%d%d%s%s", &n, &x, &y, a, b);
        int cnt[] = {0, 0};
        for (int i = 0; i < n; i++)
            cnt[a[i] != b[i]]++;
        puts((abs(x - y) > cnt[1]) || (x + y > 2 * n - cnt[1]) ? "Lying" : "Not lying");
    }
    return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
const int MAXN=80000+30;
int a[MAXN],b[MAXN];
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        int n,x,y;
        char ch;
        scanf("%d%d%d",&n,&x,&y);
        getchar();
        for(int i=0;i<n;i++){
            scanf("%c",&ch);
            a[i]=ch-'A';
        }
        getchar();
        for(int i=0;i<n;i++){
            scanf("%c",&ch);
            b[i]=ch-'A';
        }
        int cnts=0,cntd=0;
        for(int i=0;i<n;i++){
            if(a[i]==b[i]){
                cnts++;
            }
            else{
                cntd++;
            }
        }
        int flag=1;
        if(abs(x-y)>cntd) flag=0;
        if(x+y>2*n-cntd) flag=0;	//
        if(flag){
            printf("Not lying\n");
        }
        else{
            printf("Lying\n");
        }
    }
    return 0;
}*/