There are N islands in the sea, enumerated from 1 to N. Each of them is so small that we can consider them as points on a plane. You are given the Cartesian coordinates of all islands. X-axis is directed towards East and Y-axis is directed towards North.
You need to illuminate all the islands. To do this, you can place lighthouses on some of the islands. You can't place more than one lighthouse on any single island. Each lighthouse can light only one of the 4 quadrants: North-Western, North-Eastern, South-Western or South-Eastern. If some island is located on the border of an illuminated quadrant, it is considered to be illuminated as well. Note that this means that a lighthouse always illuminates it's own island as well.
Find the smallest possible number of lighthouses required to illuminate all the islands (say L). Describe their configurations — positions and quadrants illuminated — as well.

-----Input-----
The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of islands.
The ith of the following N lines contains two integers Xi and Yi denoting the coordinates of the ith island.

-----Output-----
For each test case, first line of output must contain minimum number of lighthouses required to illuminate all islands, L.
Following L lines must describe configuration of the lighthouses, one configuration per line. Description of a lighthouse configuration consists of the number of the island where the lighthouse is placed, and the direction of the quadrant (NW for North-Western, NE for North-Eastern, SW for South-Western, SE for South-Eastern) illuminated by it, separated by a single space.
If there are many possible placements, output any one of them.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 105
- The sum of N over all test cases doesn't exceed 5*105
- Absolute value of each coordinate doesn't exceed 109
- No two given islands coincide.

-----Subtasks-----
Subtask 1: (15 points)
- 1 ≤ N ≤ 8
- Absolute value of each coordinate doesn't exceed 50

Subtask 2: (85 points)
- Original constraints

-----Example-----
Input:
2
5
0 0
1 0
2 0
0 -1
0 -2
4
5 0
-5 0
0 5
0 -5

Output:
1
3 SW
2
4 NE
2 NE

-----Explanation-----
Example case 1. Also we can place lighthouse on 1st or 5th island.
Example case 2. Notice that some islands can be illuminated by more than 1 lighthouse.

Difficulty: interview

Starter code:

Solutions:
t= int(input())
for _ in range(t):
 n = int(input())
 ar = []
 y = []
 for i in range(n):
  ar.append( list(map(int,input().split())) )
  y.append(ar[-1][1])
  ar[-1].append(i)
 
 y.sort()
 mny = y[0]
 mxy = y[-1]
 ar.sort()
 ssx,ssy,ssi = ar[0]
 bbx,bby,bbi = ar[-1]
 
 sbx,sby,sbi = ar[0]
 bsx,bsy,bsi = ar[-1]
 
 for i in range(len(ar)):
  if ar[i][0]>ssx:
   sbx,sby,sbi = ar[i-1]
   break
 
 for i in range(len(ar)-1,-1,-1):
  if ar[i][0]<bsx:
   bsx,bsy,bsi = ar[i+1]
   break 
 
 if (ssy <=mny):
  print(1)
  print(ssi+1,'NE')
  continue
 if (sby>=mxy):
  print(1)
  print(sbi+1,'SE')
  continue
 if (bsy <=mny):
  print(1)
  print(bsi+1,'NW')
  continue
 if (bby>=mxy):
  print(1)
  print(bbi+1,'SW')
  continue 
 
 print(2)
 if(ssy<bby):
  print(ssi+1,'NE')
  print(bbi+1,'SW')
 else:
  print(ssi+1,'SE')
  print(bbi+1,'NW')
 


for cas in range(eval(input())):
 n = eval(input())
 pts = []
 for i in range(n):
  x, y = list(map(int, input().strip().split()))
  pts.append((x, y))

 minx = min(x for x, y in pts)
 maxx = max(x for x, y in pts)
 miny = min(y for x, y in pts)
 maxy = max(y for x, y in pts)

 for i in range(n):
  if pts[i] == (minx, miny):
   print("1\n%d NE" % (i+1))
   break
  if pts[i] == (minx, maxy):
   print("1\n%d SE" % (i+1))
   break
  if pts[i] == (maxx, miny):
   print("1\n%d NW" % (i+1))
   break
  if pts[i] == (maxx, maxy):
   print("1\n%d SW" % (i+1))
   break
 else:
  mini = min(list(range(n)), key=lambda i: pts[i]) #vvi: finding             minium in set of 0 to n-1 based comparison of key which takes pts[i]             through lambda
  maxi = max(list(range(n)), key=lambda i: pts[i])
  
  if pts[mini][1] < pts[maxi][1]:
   print("2\n%d NE\n%d SW" % (mini+1, maxi+1))
  else:
   print("2\n%d SE\n%d NW" % (mini+1, maxi+1))


for cas in range(eval(input())):
 n = eval(input())
 pts = []
 for i in range(n):
  x, y = list(map(int, input().strip().split()))
  pts.append((x, y))

 minx = min(x for x, y in pts)
 maxx = max(x for x, y in pts)
 miny = min(y for x, y in pts)
 maxy = max(y for x, y in pts)

 for i in range(n):
  if pts[i] == (minx, miny):
   print("1\n%d NE" % (i+1))
   break
  if pts[i] == (minx, maxy):
   print("1\n%d SE" % (i+1))
   break
  if pts[i] == (maxx, miny):
   print("1\n%d NW" % (i+1))
   break
  if pts[i] == (maxx, maxy):
   print("1\n%d SW" % (i+1))
   break
 else:
  mini = min(range(n), key=lambda i: pts[i])
  maxi = max(range(n), key=lambda i: pts[i])

  if pts[mini][1] < pts[maxi][1]:
   print("2\n%d NE\n%d SW" % (mini+1, maxi+1))
  else:
   print("2\n%d SE\n%d NW" % (mini+1, maxi+1))

class island:
 'number, x, y' 
 def __init__(self, x,y, number):
  self.x = x
  self.y = y
  self.number = number

def onelighthouseenough(islands, leftbottom):
 bottomleft = min(islands, key = lambda a : (a.y, a.x))

 if(leftbottom == bottomleft):
  print(1)
  print(leftbottom.number, end=' ')
  print(' NE')
  return True

 rightbottom = min(islands, key = lambda a : (-a.x, a.y))
 bottomright = min(islands, key = lambda a : (a.y, -a.x))

 if(rightbottom == bottomright):
  print(1)
  print(rightbottom.number, end=' ')
  print(' NW')
  return True

 lefttop = min(islands, key = lambda a : (a.x, -a.y))
 topleft = min(islands, key = lambda a : (-a.y, a.x))

 if(lefttop == topleft):
  print(1)
  print(lefttop.number, end=' ')
  print(' SE')
  return True

 righttop = min(islands, key = lambda a : (-a.x, -a.y))
 topright = min(islands, key = lambda a : (-a.y, -a.x))

 if(righttop == topright):
  print(1)
  print(righttop.number, end=' ')
  print(' SW')
  return True
 return False

def lighthouses(islands):
 leftbottom = min(islands, key = lambda a : (a.x, a.y))
 if(onelighthouseenough(islands, leftbottom)):
  return

 islands.remove(leftbottom)
 nextleft = min(islands, key = lambda a : a.x)

 if(leftbottom.y < nextleft.y):
  print(2)
  print(leftbottom.number, end=' ')
  print(' NE')
  print(nextleft.number, end=' ')
  print(' SE')
 else:
  print(2)
  print(leftbottom.number, end=' ')
  print(' SE')
  print(nextleft.number, end=' ')
  print(' NE')


T = int(input())

for i in range(T):
 N = int(input())
 islands = []
 for j in range(N):
  x, y = list(map(int, input().split()))
  islands.append(island(x,y, j+1))
 lighthouses(islands)
 


class island:
 'number, x, y' 
 def __init__(self,x,y,number):
  self.x = x
  self.y = y
  self.number = number

def lighthouses(islands):
 low = high = left = right = islands[0]

 left = min(islands, key = lambda a : a.x)
 right= max(islands, key = lambda a : a.x)
 low = min(islands, key = lambda a : a.y)
 high = max(islands, key = lambda a : a.y)

 if left == low:
  print(1)
  print(str(left.number) + ' NE')
 elif left == high:
  print(1)
  print(str(left.number) + ' SE')
 elif right == low:
  print(1)
  print(str(right.number) + ' NW')
 elif right == high:
  print(1)
  print(str(right.number) + ' SW')
 else:
  islands.remove(left)
  nextleft = min(islands, key = lambda a : a.x)
   
  if left.y < nextleft.y:
   print(2)
   print(str(left.number) + ' NE')
   print(str(nextleft.number) + ' SE')
  else:
   print(2)
   print(str(left.number) + ' SE')
   print(str(nextleft.number) + ' NE')


T = int(input())
for i in range(T):
 N = int(input())
 islands = []
 for j in range(N):
  x, y = list(map(int, input().split()))
  islands.append(island(x,y,j+1))
 lighthouses(islands)


class island:
 'number, x, y' 
 def __init__(self,x,y,number):
  self.x = x
  self.y = y
  self.number = number

def lighthouses(islands):
 low = high = left = right = islands[0]

 left = min(islands, key = lambda a : a.x)
 right= max(islands, key = lambda a : a.x)
 low = min(islands, key = lambda a : a.y)
 high = max(islands, key = lambda a : a.y)

 if left == low:
  print(1)
  print(str(left.number) + ' NE')
 elif left == high:
  print(1)
  print(str(left.number) + ' SE')
 elif right == low:
  print(1)
  print(str(right.number) + ' NW')
 elif right == high:
  print(1)
  print(str(right.number) + ' SW')
 else:
  islands.remove(left)
  nextleft = min(islands, key = lambda a : a.x)
   
  if left.y < nextleft.y:
   print(2)
   print(str(left.number) + ' NE')
   print(str(nextleft.number) + ' SE')
  else:
   print(2)
   print(str(left.number) + ' SE')
   print(str(nextleft.number) + ' NE')


T = int(input())
for i in range(T):
 N = int(input())
 islands = []
 for j in range(N):
  x, y = list(map(int, input().split()))
  islands.append(island(x,y,j+1))
 lighthouses(islands)


t=int(input())

ans=[]
while(t):
 X=[];
 Y=[];
 XY=[]
 
 t-=1;
 n=int(input());
 st='';
 for i in range(1,n+1):
  xi,yi=list(map(int,input().split()));
  X.append(xi);
  Y.append(yi);
  XY.append((xi,yi));
 lborder=X.index(min(X));
 rborder=X.index(max(X));
 tborder=Y.index(max(Y));
 bborder=Y.index(min(Y));
 if((X[lborder],Y[tborder])in XY):
  st='1\n'+str(XY.index((X[lborder],Y[tborder]))+1)+' SE';
 elif((X[lborder],Y[bborder])in XY):
  st='1\n'+str(XY.index((X[lborder],Y[bborder]))+1)+' NE';
 elif((X[rborder],Y[tborder])in XY):
   st='1\n'+str(XY.index((X[rborder],Y[tborder]))+1)+' SW';
 elif((X[rborder],Y[bborder])in XY):
   st='1\n'+str(XY.index((X[rborder],Y[bborder]))+1)+' NW';
 elif((rborder==lborder)):
   st='1\n'+str(tborder+1)+' SE';
 elif(tborder==bborder):
   st='1\n'+str(lborder+1)+' NE';
 else:
   if(Y[lborder]>=Y[rborder]):
    st='2\n'+str(lborder+1)+' SE\n'+str(rborder+1)+' NW';
   else:
    st='2\n'+str(lborder+1)+' NE\n'+str(rborder+1)+' SW';


 ans.append(st);
for x in ans:
 print(x)