import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
Input sc = new Input();
int q = sc.nextInt();
StringBuilder ans = new StringBuilder();
while (q-- > 0) {
int n = sc.nextInt();
HashMap<Integer, Integer> map = new HashMap<>();
boolean[] polled = new boolean[n];
for (int i = 0; i < n; i++) {
map.put(sc.nextInt(), i);
}
LinkedList<Integer> maxList = new LinkedList<>();
maxList.add(-1);
boolean flg = false;
for (int i = 0; i < n; i++) {
int pollElement = sc.nextInt();
int pollIndex = map.get(pollElement);
polled[pollIndex] = true;
int size = maxList.size();
if (pollIndex < maxList.get(size - 1)) {
flg = true;
} else if (pollIndex == maxList.get(size - 1)) {
while (--pollIndex > 0) {
if (!polled[pollIndex]) {
break;
}
}
maxList.set(size - 1, pollIndex);
} else {
while (--pollIndex > 0) {
if (!polled[pollIndex]) {
break;
}
}
maxList.add(pollIndex);
}
}
if (flg) {
ans.append("No");
} else {
ans.append("Yes");
}
ans.append('\n');
}
System.out.print(ans);
}
static class Input {
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() {
try {
in.nextToken();
} catch (IOException e) {
e.printStackTrace();
}
return (int) in.nval;
}
}
}