let n = stdin.ReadLine() |> int for i = 0 to n - 1 do let a = stdin.ReadLine().Split() |> Array.map int let b = stdin.ReadLine().Split() |> Array.map int let x = stdin.ReadLine() let idx = match x with | "WA" -> 1 | "TLE" -> 2 | "MLE" -> 3 | "OLE" -> 4 | "RE" -> 5 | _ -> 0 let mutable result = "Yes" if a.[idx] <> 0 then result <- "No" for j = 1 to 5 do if j = idx then () elif b.[j] <> 0 then result <- "No" else () result |> printfn "%s"