fork download
  1. for i in range(int(input())):
  2. count=0
  3. a=int(input())
  4. a1=[]
  5. a1=input()
  6. a1=a1.split()
  7. for j in range(a):
  8. a1[j]=int(a1[j])
  9. b=int(input())
  10. b1=[]
  11. b1=input()
  12. b1=b1.split()
  13. for j in range(b):
  14. b1[j]=int(b1[j])
  15. for j in range(0,a):
  16. g=a1[j]
  17. for s in range(0,b):
  18. if(g==b1[s]):
  19. for i in range(0,b):
  20. if(j<a):
  21. if(a1[j]==b1[i]):
  22. j=j+1
  23. count=count+1
  24. else:
  25. break
  26. else:
  27. break
  28.  
  29. if(count==(b)):
  30. print("Yes")
  31. else:
  32. print("No")
  33.  
  34.  
Success #stdin #stdout 0.01s 27712KB
stdin
3
6
1 2 3 4 10 6
3
2 3 6
6
1 2 3 4 5 6
3
2 3 4
6
22 5 4 15 6 7
2
4 15
stdout
No
Yes
Yes