#Lutece1387. 简单的双向搜索

简单的双向搜索

Migrated from Lutece 1387 简单的双向搜索

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

给定三个大小为NN的整型数组A1,A2,A3A1,A2,A3,和三个整数B1,B2,B3B1,B2,B3

接下来依次做NN次操作:对于第ii次操作(i=1,2,..,N)(i=1,2,..,N),选择一个数jj(j=1,2,3j=1,2,3),令BjBj加上Aj[i]Aj[i]

问是否存在一种操作序列,使得最后B1=B2=B3=0B1 = B2 = B3 = 0

Input

第一行四个数N(1<=N<=25),B1,B2,B3N(1<=N<=25),B1,B2,B3

接下来N行,每行三个整数,表示A1[i],A2[i]A1[i],A2[i]A3[i]A3[i]

保证A1[i],A2[i],A3[i],B1,B2,B3<=109|A1[i]|,|A2[i]|,|A3[i]|,|B1|,|B2|,|B3|<=10^9

Output

如果存在符合要求的方案,输出"YES""YES";否则输出"NO""NO"

Samples

输入数据 1

3 1 1 1
-1 2 3
1 -1 2
2 3 -1

输出数据 1

YES

输入数据 2

3 1 1 1
1 1 1
1 1 1
1 1 1

输出数据 2

NO

Resources

2016 UESTC Training for Search Algorithm & String