Many things in this first paragraph are references to some pretty famous YouTube stars, so be careful about rephrasing. Thanks! 
Michael, Kevin and Jake are sharing a cake, in celebration of their Webby award. They named it VCake. Unlike other cakes they considered, this one has finite volume and surface area. It's shaped as a normal rectangular cake with dimensions R centimeters by C centimeters. For the purposes of this problem, we can forget about three dimensions and think of a cake as just a 2D rectangle.
Chef will now cut the cake into three pieces, one for each person. However, the cake's shape and Chef's really old tools pose a few restrictions:

- Chef can only cut the cake, or a cake piece, across a line parallel to one of its sides. 
- Chef can only cut the cake, or a cake piece, from end to end. That is, she cannot cut the cake partially. 
- Chef can only cut the cake, or a cake piece, such that the sides of the resulting pieces (which will be rectangular in shape) are integers. 

In addition, Michael, Kevin and Jake also have a few preferences of their own:

- They want their pieces to be connected (in one piece), and rectangular in shape.
- Michael wants his piece to have an area exactly M square centimeters. (Again, forget about a third dimension.)
- Kevin wants his piece to have an area exactly K square centimeters.
- Jake wants his piece to have an area exactly J square centimeters.

With these restrictions, Chef is at a loss. Is it possible for Chef to accomplish this task? Please note that the entire cake should be used. There should be no leftover cake.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case consists of a single line containing five space separated integers R, C M, K and J.

-----Output-----
For each test case, output a single line containing either “Yes” or “No” (without quotes), denoting whether Chef can accomplish the task or not.

-----Constraints-----
- 1 ≤ T ≤ 105
- 1 ≤ R, C ≤ 109
- 1 ≤ M, K, J ≤ 1018

-----Example-----
Input:4
4 5 10 4 6
4 5 6 10 4
4 5 4 6 10
2 2 2 2 2

Output:Yes
Yes
Yes
No

-----Explanation-----
Example case 1. In this case, Chef can accomplish the task by doing the following slicing.  
pre tt
_ _ _ _ _       _ _ _ _ _       _ _ _ _ _       _________ 
|         |     |         |     |         |     |M M M M M|
|         | -- |_ _ _ _ _| -- |_ _ _ _ _| -- |M_M_M_M_M|
|         |     |         |     |     |   |     |J J J|K K|
|_ _ _ _ _|     |_ _ _ _ _|     |_ _ _|_ _|     |J_J_J|K_K|
/tt /pre
I'll make an image if I have time 
Example case 4. Here, Michael, Kevin and Jake each wants a piece with area 2, but the total area of the cake is only 2×2 = 4. This means the task is impossible.

Difficulty: interview

Starter code:

Solutions:
#!/usr/bin/python
import sys

def __starting_point():
 t = int(input())
 for iteration in range(t):
  r,c,m_inp,k_inp,j_inp = input().strip().split(" ")
  r=int(r)
  c=int(c)
  m_inp=int(m_inp)
  k_inp=int(k_inp)
  j_inp=int(j_inp)

  ans = ""
  if (r*c) != (m_inp+k_inp+j_inp):
   print("No")
   continue
  else:
   flag = False
   for i in range(6):
    if flag:
     break
    if i==0:
     m = m_inp
     k = k_inp
     j = j_inp
    elif i==1:
     m = j_inp
     k = m_inp
     j = k_inp
    elif i==2:
     m = k_inp
     k = j_inp
     j = m_inp
    elif i==3:
     m = m_inp
     k = j_inp
     j = k_inp
    elif i==4:
     m = k_inp
     k = m_inp
     j = j_inp
    elif i==5:
     m = j_inp
     k = k_inp
     j = m_inp
    if m%r == 0:
     r_remain_1 = r
     c_remain_1 = c-(m/r)
     
     if k%r_remain_1 == 0:
      r_remain_2 = r_remain_1
      c_remain_2 = c_remain_1 - (k/r_remain_1)
      if r_remain_2*c_remain_2 == j:
       print("Yes")
       flag = True
       continue
     if k%c_remain_1 == 0:
      c_remain_2 = c_remain_1
      r_remain_2 = r_remain_1 - (k/c_remain_1)
      if r_remain_2*c_remain_2 == j:
       print("Yes")
       flag = True
       continue
     
     if j%r_remain_1 == 0:
      r_remain_2 = r_remain_1
      c_remain_2 = c_remain_1 - (j/r_remain_1)
      if r_remain_2*c_remain_2 == k:
       print("Yes")
       flag = True
       continue
     if j%c_remain_1 == 0:
      c_remain_2 = c_remain_1
      r_remain_2 = r_remain_1 - (j/c_remain_1)
      if r_remain_2*c_remain_2 == k:
       print("Yes")
       flag = True
       continue
    
    if m%c == 0:
     c_remain_1 = c
     r_remain_1 = r-(m/c) 

     if k%r_remain_1 == 0:
      r_remain_2 = r_remain_1
      c_remain_2 = c_remain_1 - (k/r_remain_1)
      if r_remain_2*c_remain_2 == j:
       print("Yes")
       flag = True
       continue
     if k%c_remain_1 == 0:
      c_remain_2 = c_remain_1
      r_remain_2 = r_remain_1 - (k/c_remain_1)
      if r_remain_2*c_remain_2 == j:
       print("Yes")
       flag = True
       continue
     
     if j%r_remain_1 == 0:
      r_remain_2 = r_remain_1
      c_remain_2 = c_remain_1 - (j/r_remain_1)
      if r_remain_2*c_remain_2 == k:
       print("Yes")
       flag = True
       continue
     if j%c_remain_1 == 0:
      c_remain_2 = c_remain_1
      r_remain_2 = r_remain_1 - (j/c_remain_1)
      if r_remain_2*c_remain_2 == k:
       print("Yes")
       flag = True
       continue
   if not flag:
    print("No")
__starting_point()

import string

T=eval(input())
for x in range(T):
 #a=raw_input()
 b=input().split()
 R=int(b[0])
 C=int(b[1])
 M=int(b[2])
 K=int(b[3])
 J=int(b[4])
 if (R*C)!=M+K+J:
  print("No")
  continue
 if R==1 or C==1:
  print("Yes")
  continue

 if M%R==0:
  C=C-M/R
  if K%R==0 or K%C==0 or J%R==0 or J%C==0:
   print("Yes")
   continue
  else:
   C=C+M/R
 if M%C==0:
  R=R-M/C
  if K%R==0 or K%C==0 or J%R==0 or J%C==0:
   print("Yes")
   continue
  else:
   R=R+M/C
 if K%R==0:
  C=C-K/R
  if M%R==0 or M%C==0 or J%R==0 or J%C==0:
   print("Yes")
   continue
  else:
   C=C+K/R 
 if K%C==0:
  R=R-K/C
  if M%R==0 or M%C==0 or J%R==0 or J%C==0:
   print("Yes")
   continue
  else:
   R=R+K/C
 if J%R==0:
  C=C-J/R
  if K%R==0 or K%C==0 or M%R==0 or M%C==0:
   print("Yes")
   continue
  C=C+J/R
 if J%C==0:
  R=R-J/C
  if K%R==0 or K%C==0 or M%R==0 or M%C==0:
   print("Yes")
   continue
  else:
   R=R+J/C
    
   
 print("No")

def twonocheck(k, j, r, c):
 if k % r == 0:
  nc = c - k / r
  if r * nc == j:
   return True
 if k % c == 0:
  nr = r - k / c
  if nr * c == j:
   return True
 return False


def nocheck(m, k, j, r, c):
 if m % r == 0:
  nc = c - m / r
  if nc != 0:
   if twonocheck(k, j, r, nc):
     return True
   elif twonocheck(j, k, r, nc):
    return True
 if m % c == 0:
  nr = r - m / c
  if nr != 0:
   if twonocheck(k, j, nr, c):
    return True
   elif twonocheck(j, k, nr, c):
    return True
 return False

for i in range(int(input())):
 inp = input().split()
 r = int(inp[0])
 c = int(inp[1])
 m = int(inp[2])
 k = int(inp[3])
 j = int(inp[4])
 # r, c, m, k, j = map(int, raw_input().split())

 if nocheck(m, k, j, r, c):
  print("Yes")
 # elif nocheck(m, j, k, r, c):
 #     print "Yes"
 elif nocheck(j, m, k, r, c):
  print("Yes")
 # elif nocheck(j, k, m, r, c):
 #     print "Yes"
 elif nocheck(k, m, j, r, c):
  print("Yes")
 # elif nocheck(k, j, m, r, c):
 #     print "Yes"
 else:
  print("No")


for t in range(int(input())):
 r,c,p1,p2,p3=list(map(int,input().split()))
 if ((r*c)!=(p1+p2+p3)):
  print('No')
  continue
 if (p1%r)==0:
  nc=c-(p1/r)
  if ((p2%r==0 and p3%r==0) or (p2%nc==0 and p3%nc==0)):
   print('Yes')
   continue
 if (p2%r)==0:
  nc=c-(p2/r)
  if ((p1%r==0 and p3%r==0) or (p1%nc==0 and p3%nc==0)):
   print('Yes')
   continue
 if (p3%r)==0:
  nc=c-(p3/r)
  if ((p2%r==0 and p1%r==0) or (p2%nc==0 and p1%nc==0)):
   print('Yes')
   continue
 if (p1%c)==0:
  nr=r-(p1/c)
  if ((p2%nr==0 and p3%nr==0) or (p2%c==0 and p3%c==0)):
   print('Yes')
   continue
 if (p2%c)==0:
  nr=r-(p2/c)
  if ((p1%nr==0 and p3%nr==0) or (p1%c==0 and p3%c==0)):
   print('Yes')
   continue
 if (p3%c)==0:
  nr=r-(p3/c)
  if ((p2%nr==0 and p1%nr==0) or (p2%c==0 and p1%c==0)):
   print('Yes')
   continue
 print('No')


def cut2(x, y, m, n):
 #print "got {}*{} and {},{}".format(x,y,m,n)
 return m%x==0 or n%y==0
 
def cut1(x, y, l, m, n):
 if x*y != l+m+n:
  return False
 else:
  if l%x==0:
   if cut2(x, y-l/x, m, n):
    return True
  if l%y==0:
   if cut2(x-l/y, y, m, n):
    return True
  if m%x==0:
   if cut2(x, y-m/x, l, n):
    return True
  if not m%y:
   if cut2(x-m/y, y, l, n):
    return True
  if not n%x:
   if cut2(x, y-n/x, m, l):
    return True
  if not n%y:
   if cut2(x-n/y, y, m, l):
    return True
  return False

t = int(input())

for i in range(t):
 x, y, l, m, n = list(map(int, input().strip().split()))
 print("Yes" if cut1(x,y,l,m,n) else "No")


# your code goes here
n = input()
n = int(n)
for i in range (0,n):
 r,c,j,k,m = list(map(int, input().split(" ")))
 if(r*c != m + k +j):
  print("No")
 elif m%c == 0 and (k*c)%(j+k)==0 and (j*c)%(j+k)==0:
  print("Yes")
 elif j%c == 0 and (k*c)%(m+k)==0 and (m*c)%(m+k)==0:
  print("Yes")
 elif k%c == 0 and (j*c)%(j+m)==0 and (m*c)%(j+m)==0:
  print("Yes")
 elif m%r == 0 and (k*r)%(j+k)==0 and (j*r)%(j+k)==0:
  print("Yes")
 elif j%r == 0 and (k*r)%(m+k)==0 and (m*r)%(m+k)==0:
  print("Yes")
 elif k%r == 0 and (j*r)%(m+j)==0 and (m*r)%(m+j)==0:
  print("Yes")
 elif k%c == 0 and j%c==0 and m%c==0:
  print("Yes")
 elif k%r == 0 and j%r==0 and m%r==0:
  print("Yes")
 else:
  print("No")

def check2(r,x,k,j):
 if k%r==0 and j%r==0:
  return True
 if (k%x ==0) and j%x ==0:
  return True
 return False

def check(r,c,m,k,j):
 if m%r!=0:
  return False
 x = c - (m/r)
 return check2(r,x,k,j)

for _ in range(int(input())):
 r,c,m,k,j = list(map(int, input().split()))
 if r*c != m+k+j :
  print("No")
 else:
  b =False
  b|=check(r,c,m,k,j);
  b|=check(r,c,k,m,j);
  b|=check(r,c,j,m,k);
  b|=check(c,r,m,k,j);
  b|=check(c,r,k,m,j);
  b|=check(c,r,j,m,k);
  if b:
   print('Yes')
  else:
   print('No') 


try:
 t=eval(input())
except EOFError:
 t=0
while(t):
 try:
  r,c,m,k,j=list(map(int,input().split()))
 except EOFError:
  r=1
  c=1
  m=1
  k=1
  j=1
 area1=r*c
 area2=m+k+j
 if(area1!=area2):
  print("No")
 else:
  f=0
  if(m%r==0):
   rr=r
   cc=c
   a=m//rr
   cc=cc-a
   if(((k%rr==0) and (j%rr==0)) or ((k%cc==0) and (j%cc==0))):
    f=1
  if(m%c==0 and f==0):
   rr=r
   cc=c
   a=m//cc
   rr-=a
   if(((k%rr==0) and (j%rr==0)) or ((k%cc==0) and (j%cc==0))):
    f=1
  if(k%r==0 and f==0):
   rr=r
   cc=c
   a=k//rr
   cc=cc-a
   if(((m%rr==0) and (j%rr==0)) or ((m%cc==0) and (j%cc==0))):
    f=1
  if(k%c==0 and f==0):
   rr=r
   cc=c
   a=k//cc
   rr=rr-a
   if(((m%rr==0) and (j%rr==0)) or ((m%cc==0) and (j%cc==0))):
    f=1
  if(j%r==0 and f==0):
   rr=r
   cc=c
   a=j//rr
   cc=cc-a
   if(((k%rr==0) and (m%rr==0)) or ((k%cc==0) and (m%cc==0))):
    f=1
  if(j%c==0 and f==0):
   rr=r
   cc=c
   a=j//cc
   rr=rr-a
   if(((k%rr==0) and (m%rr==0)) or ((k%cc==0) and (m%cc==0))):
    f=1
  if(f==1):
   print("Yes")
  else:
   print("No")
 t=t-1


import sys
import itertools as it

def main():
 t=int(input())
 while t>0:
  t-=1
  r,c,m,k,j=list(map(int,input().split()))
  if m+k+j!=r*c:
   print('No')
  else:
   l=[m,k,j]
   l=list(it.permutations(l))
   chk=0
   for x in l:
    f=test(x,r,c) + test(x,c,r)
    if f>=1:
     chk=1
     break
   if chk==1:
    print('Yes')
   else:
    print('No')
def test(l,r,c):
 for x in range(2,0,-1):
  if l[x]%r==0:
   d=l[x]/r
   c=c-d
  elif l[x]%c==0:
   d=l[x]/c
   r=r-d
  else:
   return 0
  #print r,l,c
  if r==0 or c==0:
   return 0
 if r*c==l[0]:
  return 1
 else:
  return 0

def __starting_point():
 main()

__starting_point()

for _ in range(eval(input())):
 r,c,x,y,z=list(map(int,input().split()))
 s=r*c
 f=x+y+z
 if x+y+z==s:
  m=x
  if m%r==0 or m%c==0:
   if m%r==0:
    p=m//r
    q=c-p
    if p<c:
     g=z
     h=y
     k=r
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
   if m%c==0:
    p=m//c
    q=r-p
    if p<r:
     g=z
     h=y
     k=c
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
  m=y
  if m%r==0 or m%c==0:
   if m%r==0:
    p=m//r
    q=c-p
    if p<c:
     g=x
     h=z
     k=r
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
   if m%c==0:
    p=m//c
    q=r-p
    if p<r:
     g=x
     h=z
     k=c
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
  m=z
  if m%r==0 or m%c==0:
   if m%r==0:
    p=m//r
    q=c-p
    if p<c:
     g=x
     h=y
     k=r
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
   if m%c==0:
    p=m//c
    q=r-p
    if p<r:
     g=x
     h=y
     k=c
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
     q,k=k,q
     if g%q==0:
      if((k-(g/q))*q)==h:
       print("Yes")
       continue
  
 print("No")



def solve(r, c, ar ):
 
 if not r*c == ar[0] + ar[1] + ar[2]:
  return "No"
 
 if ar[0] % r == ar[1] % r == ar[2] % r == 0:
  if ar[0] / r + ar[1] / r + ar[2] / r == c:
   return "Yes"
  
 if ar[0] % c == ar[1] % c == ar[2] % c == 0:
  if ar[0] / c + ar[1] / c + ar[2] / c == r:
   return "Yes" 
  
 for i in range(len(ar)):
  if ar[i] % r == 0:
   cnt = 0
   sml = 0
   sma = 0
   c2 = c - ar[i] / r
   for j in range(len(ar)):
    if i == j:
     continue
    if ar[j] % c2 == 0:
     cnt += 1
     sml += ar[j] / c2
     sma += ar[j]
   if cnt == 2 and sml == r:
    if sma + ar[i] == r * c:
     return "Yes"
  if ar[i] % c == 0:
   cnt = 0
   sml = 0
   sma = 0
   r2 = r - ar[i] / c
   for j in range(len(ar)):
    if i == j:
     continue
    if ar[j] % r2 == 0:
     cnt += 1
     sml += ar[j] / r2
     sma += ar[j]
   if cnt == 2 and sml == c:
    if sma + ar[i] == r * c:
     return "Yes" 
 return "No"
   
  
for cas in range(eval(input())):
 r, c, m, k, j = list(map(int, input().strip().split()))
 print(solve( r, c, [m, k, j] ))
 
 


def get_result(r,c,dims):
 if len(dims)==0:
  if r*c==0:
   return 1
  return 0;
 for i in range(len(dims)):
  newdims = [dims[x] for x in range(len(dims)) if x!=i]
  if r!=0 and dims[i]%r==0:
   if get_result(r,c-dims[i]/r,newdims):
    return 1
  if c!=0 and dims[i]%c==0:
   if get_result(r-dims[i]/c,c,newdims):
    return 1
 return 0
   
  
 

def __starting_point():
 num = int(input())
 for i in range(num):
  R,C,M,K,J = [int(x) for x in input().split()]
  if(get_result(R,C,[M,K,J])):
   print("Yes")
  else:
   print("No")
__starting_point()

for x in range(0,eval(input())):
 p=list(map(int,input().split()))
 a=p[2]
 b=p[3]
 c=p[4]
 ro=p[0]
 co=p[1]
 ar=ro*co
 if a==ar or b==ar or c==ar:
  print("No")
  continue
 if a%ro==0:
  nr=ro
  nc=co-(a/ro)
  if b%nr==0 and c%nr==0 and (b/nr)+(c/nr)==nc:
   print("Yes")
   continue
  else:
   if b%nc==0 and c%nc==0 and (b/nc)+(c/nc)==nr:
    print("Yes")
    continue
 if b%ro==0:
  nr=ro
  nc=co-(b/ro)
  if a%nr==0 and c%nr==0 and (a/nr)+(c/nr)==nc:
   print("Yes")
   continue
  else:
   if a%nc==0 and c%nc==0 and (a/nc)+(c/nc)==nr:
    print("Yes")
    continue
 if c%ro==0:
  nr=ro
  nc=co-(c/ro)
  if b%nr==0 and a%nr==0 and (b/nr)+(a/nr)==nc:
   print("Yes")
   continue
  else:
   if b%nc==0 and a%nc==0 and (b/nc)+(a/nc)==nr:
    print("Yes")
    continue
 if a%co==0:
  nr=ro-(a/co)
  nc=co
  if b%nr==0 and c%nr==0 and (b/nr)+(c/nr)==nc:
   print("Yes")
   continue
  else:
   if b%nc==0 and c%nc==0 and (b/nc)+(c/nc)==nr:
    print("Yes")
    continue
 if b%co==0:
  nr=ro-(b/co)
  nc=co
  if a%nr==0 and c%nr==0 and (a/nr)+(c/nr)==nc:
   print("Yes")
   continue
  else:
   if a%nc==0 and c%nc==0 and (a/nc)+(c/nc)==nr:
    print("Yes")
    continue
 if c%co==0:
  nr=ro-(c/co)
  nc=co
  if b%nr==0 and a%nr==0 and (b/nr)+(a/nr)==nc:
   print("Yes")
   continue
  else:
   if b%nc==0 and a%nc==0 and (b/nc)+(a/nc)==nr:
    print("Yes")
    continue
 print("No")


t = int (eval(input()))

while t > 0:
 t -= 1
 r, c, m, j, k = list(map (int, input().split()))
 area = r * c
 if m + j + k != area:
  print("No")
  continue
 l = r
 b = c
 if m % l == 0:
  b -= m/l
  if b > 0 and (j % l == 0 or j % b == 0 or k %l == 0 or k % b == 0):
   print("Yes")
   continue
 l = r
 b = c
 if m % b == 0:
  l -= m/b
  if l > 0 and (j % l == 0 or j % b == 0 or k %l == 0 or k % b == 0):
   print("Yes")
   continue
 
 l = r
 b = c
 if j % l == 0:
  b -= j/l
  if b > 0 and (m % l == 0 or m % b == 0 or k %l == 0 or k % b == 0):
   print("Yes")
   continue
 l = r
 b = c
 if j % b == 0:
  l -= j/b
  if l > 0 and (m % l == 0 or m % b == 0 or k %l == 0 or k % b == 0):
   print("Yes")
   continue
 
 l = r
 b = c
 if k % l == 0:
  b -= k/l
  if b > 0 and (j % l == 0 or j % b == 0 or m %l == 0 or m % b == 0):
   print("Yes")
   continue
 l = r
 b = c
 if k % b == 0:
  l -= k/b
  if l > 0 and (j % l == 0 or j % b == 0 or m % l == 0 or m % b == 0):
   print("Yes")
   continue
 
 print("No")


def do_cut(r,c,m,k,j,mask):
 if mask==0:
  if (r==0 or c==0):
   return True
  else:
   return False

 if r<=0 or c<=0:
  return False

 cut_poss = False
 ans = False

 if m%r==0 and (mask&4):
  ans = ans or do_cut(r,c-(m/r),m,k,j,mask&3)
  cut_poss = True
 if m%c==0 and (mask&4):
  ans = ans or do_cut(r-(m/c),c,m,k,j,mask&3)
  cut_poss = True

 if k%r==0 and (mask&2):
  ans = ans or do_cut(r,c-(k/r),m,k,j,mask&5)
  cut_poss = True
 if k%c==0 and (mask&2):
  ans = ans or do_cut(r-(k/c),c,m,k,j,mask&5)
  cut_poss = True

 if j%r==0 and (mask&1):
  ans = ans or do_cut(r,c-(j/r),m,k,j,mask&6)
  cut_poss = True
 if j%c==0 and (mask&1):
  ans = ans or do_cut(r-(j/c),c,m,k,j,mask&6)
  cut_poss = True

 if not cut_poss:
  return False

 return ans


def solve():
 t = eval(input())
 while t>0:
  r,c,m,k,j = list(map(int,input().split()))
  ans = do_cut(r,c,m,k,j,7)
  print('Yes' if ans else 'No')
  t-=1


solve() 



def can_cut_h(r,c, s1, s2):
 if (s1 % r != 0) and (s2 % r != 0):
  return None
 c1, c2 = s1 / r, s2 / r
 if c1 + c2 != c:
  return None

 return c2

def can_cut_v(r,c, s1, s2):
 if (s1 % c != 0) and (s2 % c != 0):
  return None
 r1, r2 = s1 / c, s2 / c
 if r1 + r2 != r:
  return None

 return r2

def solve(r,c,m,k,j):
 if (m + k + j) != r*c:
  return "No",
 in_order = [m, k, j]
 for _ in range(3):
  s1 = in_order.pop()
  s2, s3 = in_order
  in_order.insert(0, s1)
  v_r = can_cut_v(r, c, s1, s2 + s3)
  h_c = can_cut_h(r, c, s1, s2 + s3)
  if v_r is not None:
   if can_cut_h(v_r, c, s2, s3) or can_cut_v(v_r, c, s2, s3):
    return "Yes",
  if h_c is not None:
   if can_cut_h(r, h_c, s2, s3) or can_cut_v(r, h_c, s2, s3):
    return "Yes",
 return "No",


def read_input():
 r,c,m,k,j = list(map(int, input().split()))
 return r,c,m,k,j

def __starting_point():
 t = int(input())
 for i in range(t):
  res = list(map(str, solve(*read_input())))
  print(" ".join(res))
 # print solve(4, 5, 10, 4, 6)
 # print solve(4, 5, 6, 10, 4)
 # print solve(4, 5, 4, 6, 10)
 # print solve(2, 2, 2, 2, 2)

__starting_point()