#include<bits/stdc++.h>
#define sp ' '
#define fi first
#define se second
using namespace std;
pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        val[{b-a,a+b}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        cin >> a;
        auto it=val.lower_bound({a,0});
        //cout << it->fi.fi <<sp << it->fi.se <<endl;
        if(it==val.end() || it->fi.fi!=a || (it->se.fi+1)*(it->se.se+1)>i+1) return puts("NO"), 0;
        ans[i]=it->se;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].fi,ans[i].se);
    return 0;
}


#include<bits/stdc++.h>
#define sp ' '
#define fi first
#define se second
using namespace std;
pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        val[{b-a,1}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        cin >> a;
        auto it=val.lower_bound({a,0});
        //cout << it->fi.fi <<sp << it->fi.se <<endl;
        if(it==val.end() || it->fi.fi!=a || (it->se.fi+1)*(it->se.se+1)>i+1) return puts("NO"), 0;
        ans[i]=it->se;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].fi,ans[i].se);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

pair<int,int>  ans[100000];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        scanf("%d %d", &a, &b);
        val[{b-a,a+b}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d", &a);
        auto it=val.lower_bound({a,0});
        if(it==val.end() || it->first.first!=a || (it->second.first+1)*(it->second.second+1)>i+1) return puts("NO"), 0;
        ans[i]=it->second;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


#include<bits/stdc++.h>
#define sp ' '
#define fi first
#define se second
using namespace std;
pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        val[{b-a,0}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        cin >> a;
        auto it=val.lower_bound({a,0});
        //cout << it->fi.fi <<sp << it->fi.se <<endl;
        if(it==val.end() || it->fi.fi!=a || (it->se.fi+1)*(it->se.se+1)>i+1) return puts("NO"), 0;
        ans[i]=it->se;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].fi,ans[i].se);
    return 0;
}


#include<bits/stdc++.h>
#define sp ' '
#define fi first
#define se second
using namespace std;
pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        scanf("%d %d", &a, &b);
        val[{b-a,a+b}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d", &a);
        auto it=val.lower_bound({a,0});
        if(it==val.end() || it->fi.fi!=a || (it->se.fi+1)*(it->se.se+1)>i+1) return puts("NO"), 0;
        ans[i]=it->se;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].fi,ans[i].se);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        scanf("%d %d", &a, &b);
        val[{b-a,a+b}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        scanf("%d", &a);
        auto it=val.lower_bound({a,0});
        if(it==val.end() || it->first.first!=a || (it->second.first+1)*(it->second.second+1)>i+1) return puts("NO"), 0;
        ans[i]=it->second;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


#include<bits/stdc++.h>
#define sp ' '
#define fi first
#define se second
using namespace std;
pair<int,int>  ans[100100];
int main()
{
    int n,a,b;
    scanf("%d", &n);
    map<pair<int,int> , pair<int,int> > val;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        val[{b-a,a+b}]={a,b};
    }
    for(int i=0;i<n;i++)
    {
        cin >> a;
        auto it=val.lower_bound({a,0});
        //cout << it->se.fi+1 <<sp << it->se.se+1 <<endl;
        if(it==val.end() || it->fi.fi!=a ) return puts("NO"), 0;
        ans[i]=it->se;
        val.erase(it);
    }
    puts("YES");
    for(int i=0;i<n;i++)
        printf("%d %d\n",ans[i].fi,ans[i].se);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int n;
vector<pair<int, int>> P(100005);
int W[100005];
int Smaller[100005];
int Ind[100005];

bool assign(int p) {
  if(p == n) return true;
  int lowest = Smaller[p];

  for(int i = 0; i < n; i++) {
    if(Ind[i] == -1 && W[i] == P[p].second - P[p].first) {
      Ind[i] = p;
      if (assign(p+1)) return true;
      Ind[i] = -1;
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> P[i].first >> P[i].second;
  for (int i = 0; i < n; i++) cin >> W[i];
  for (int i = 0; i < n; i++) Ind[i] = -1;

  for(int i = 0; i < n; i++) {
    Smaller[i] = P[i].first * P[i].second;
  }

  if (assign(0)) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      cout << P[Ind[i]].first << " " << P[Ind[i]].second << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int64_t A[200005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    cin >> A[i];
  }

  int64_t right = 0;
  int64_t steps = 0;
  for(int i = 0; i < n; i++) {
    steps += abs(right - A[i]);
    right = A[i];
  }
  cout << steps << endl;
  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int n;
map<int, vector<int>> M1;
map<int, vector<pair<int,int>>> M2;
map<int, pair<int,int>> Ind;
vector<pair<int, int>> P(100005);
int W[100005];

bool cmp(const pair<int,int>& p1, const pair<int,int>& p2) {
  return (p1.first < p2.first || (p1.first == p2.first && p1.second <= p2.second));
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> P[i].first >> P[i].second;
    M2[P[i].second - P[i].first].emplace_back(P[i].first, P[i].second);
  }
  for (int i = 0; i < n; i++) {
    cin >> W[i];
    M1[W[i]].push_back(i);
  }
  for(const auto& p: M1) {
    if(p.second.size() != M2[p.first].size()) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for(auto& p: M2) {
    auto& els = p.second;
    sort(begin(els), end(els), cmp);
  }

  for(const auto& p: M2) {
    auto it1 = begin(p.second);
    auto it2 = begin(M1[p.first]);
    while(it1 != end(p.second)) {
      Ind[*it2] = *it1;
      ++it1;
      ++it2;
    }

  }
  for(const auto& p: Ind) {
    if(p.first < p.second.first*p.second.second) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for(const auto& p: Ind) {
    cout << p.second.first << " " << p.second.second << endl;
  }

  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int n;
vector<pair<int, int>> P(100005);
int W[100005];
int Smaller[100005];
int Ind[100005];

bool cmp(const pair<int,int>& p1, const pair<int,int>& p2) {
  return (p1.first <= p2.first && p1.second <= p2.second);
}

bool assign(int p) {
  if(p == n) return true;
  int lowest = Smaller[p];

  for(int i = lowest; i < n; i++) {
    if(Ind[i] == -1 && W[i] == P[p].second - P[p].first) {
      Ind[i] = p;
      if (assign(p+1)) return true;
      Ind[i] = -1;
    }
    else if(Ind[i] != -1 && cmp(P[p], P[Ind[i]])) {
      return false;
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> P[i].first >> P[i].second;
  for (int i = 0; i < n; i++) cin >> W[i];
  for (int i = 0; i < n; i++) Ind[i] = -1;

  for(int i = 0; i < n; i++) {
    Smaller[i] = P[i].first * P[i].second;
  }

  if (assign(0)) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      cout << P[Ind[i]].first << " " << P[Ind[i]].second << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int n;
map<int, vector<int>> M1;
map<int, vector<pair<int,int>>> M2;
map<int, pair<int,int>> Ind;
vector<pair<int, int>> P(100005);
int W[100005];

bool cmp(const pair<int,int>& p1, const pair<int,int>& p2) {
  return (p1.first < p2.first || (p1.first == p2.first && p1.second <= p2.second));
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> P[i].first >> P[i].second;
    M2[P[i].second - P[i].first].emplace_back(P[i].first, P[i].second);
  }
  for (int i = 0; i < n; i++) {
    cin >> W[i];
    M1[W[i]].push_back(i);
  }
  for(const auto& p: M1) {
    if(p.second.size() != M2[p.first].size()) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for(auto& p: M2) {
    auto& els = p.second;
    sort(begin(els), end(els), cmp);
  }

  for(const auto& p: M2) {
    auto it1 = begin(p.second);
    auto it2 = begin(M1[p.first]);
    while(it1 != end(p.second)) {
      Ind[*it2] = *it1;
      ++it1;
      ++it2;
    }

  }
  vector<int> r(n, -1);
  vector<int> c(n, -1);
  for(const auto& p: Ind) {
    int x = p.second.first;
    int y = p.second.second;
    if (r[x] != y - 1 || c[y] != x - 1) {
      puts("NO");
      return 0;
    }
    r[x]++;
    c[y]++;
  }
  cout << "YES" << endl;
  for(const auto& p: Ind) {
    cout << p.second.first << " " << p.second.second << endl;
  }

  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int n;
map<int, vector<int>> M1;
map<int, vector<pair<int,int>>> M2;
map<int, pair<int,int>> Ind;
vector<pair<int, int>> P(100005);
int W[100005];

bool cmp(const pair<int,int>& p1, const pair<int,int>& p2) {
  return (p1.first < p2.first || (p1.first == p2.first && p1.second <= p2.second));
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> P[i].first >> P[i].second;
    M2[P[i].second - P[i].first].emplace_back(P[i].first, P[i].second);
  }
  for (int i = 0; i < n; i++) {
    cin >> W[i];
    M1[W[i]].push_back(i);
  }
  for(const auto& p: M1) {
    if(p.second.size() != M2[p.first].size()) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for(auto& p: M2) {
    auto& els = p.second;
    sort(begin(els), end(els), cmp);
  }

  for(const auto& p: M2) {
    auto it1 = begin(p.second);
    auto it2 = begin(M1[p.first]);
    while(it1 != end(p.second)) {
      Ind[*it2] = *it1;
      ++it1;
      ++it2;
    }

  }
  for(const auto& p: Ind) {
    if(p.first <= p.second.first*p.second.second) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for(const auto& p: Ind) {
    cout << p.second.first << " " << p.second.second << endl;
  }

  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int n;
vector<pair<int, int>> P(100005);
int W[100005];
int Smaller[100005];
int Ind[100005];

bool cmp(const pair<int,int>& p1, const pair<int,int>& p2) {
  return (p1.first <= p2.first && p1.second <= p2.second);
}

bool assign(int p) {
  if(p == n) return true;
  int lowest = Smaller[p];

  for(int i = 0; i < lowest; i++) if(Ind[i] != -1 && cmp(P[p], P[Ind[i]])) return false;

  for(int i = lowest; i < n; i++) {
    if(Ind[i] == -1 && W[i] == P[p].second - P[p].first) {
      Ind[i] = p;
      if (assign(p+1)) return true;
      Ind[i] = -1;
    }
    else if(Ind[i] != -1 && cmp(P[p], P[Ind[i]])) {
      return false;
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> P[i].first >> P[i].second;
  for (int i = 0; i < n; i++) cin >> W[i];
  for (int i = 0; i < n; i++) Ind[i] = -1;

  for(int i = 0; i < n; i++) {
    Smaller[i] = P[i].first * P[i].second;
  }

  if (assign(0)) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      cout << P[Ind[i]].first << " " << P[Ind[i]].second << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int n;
vector<pair<int, int>> P(100005);
int W[100005];
int Smaller[100005], Larger[100005];
int Ind[100005];

bool cmp(const pair<int, int>& p1, const pair<int, int>& p2) {
  return ((p1.first < p2.first && p1.second <= p2.second) ||
          (p1.first <= p2.first && p1.second < p2.second));
}

bool assign(int p) {
  if(p == n) return true;
  int lowest = Smaller[p];

  for(int i = lowest; i < n; i++) {
    if(Ind[i] == -1 && W[i] == P[p].second - P[p].first) {
      Ind[i] = p;
      if (assign(p+1)) {
        return true;
      }
      Ind[i] = -1;
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> P[i].first >> P[i].second;
  for (int i = 0; i < n; i++) cin >> W[i];
  for (int i = 0; i < n; i++) Ind[i] = -1;

  //sort(begin(P), end(P), cmp);
  for(int i = 0; i < n; i++) {
    Smaller[i] = P[i].first * P[i].second;
    //auto it = upper_bound(begin(P), end(P), P[i], cmp);
    //if(it == end(P)) Larger[i] = 0;
    //else Larger[i] = distance(it, begin(P)+i);
  }

  if (assign(0)) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      cout << P[Ind[i]].first << " " << P[Ind[i]].second << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int n;
vector<pair<int, int>> P(100005);
int W[100005];
int Smaller[100005];
int Ind[100005];

bool assign(int p) {
  if(p == n) return true;
  int lowest = Smaller[p];

  for(int i = lowest; i < n; i++) {
    if(Ind[i] == -1 && W[i] == P[p].second - P[p].first) {
      Ind[i] = p;
      if (assign(p+1)) return true;
      Ind[i] = -1;
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> P[i].first >> P[i].second;
  for (int i = 0; i < n; i++) cin >> W[i];
  for (int i = 0; i < n; i++) Ind[i] = -1;

  for(int i = 0; i < n; i++) {
    Smaller[i] = P[i].first * P[i].second;
  }

  if (assign(0)) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      cout << P[Ind[i]].first << " " << P[Ind[i]].second << endl;
    }
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

#define X first
#define Y second

using namespace std;

typedef pair<int, int> par;

const int MAXN = 1e5 + 10;

map<int, int> mapa, mapa2;
map<int, vector<int> > pos;
int n;
int val[MAXN];
par cord[MAXN];
int cnt[MAXN], cnt2[MAXN];
int w[MAXN];

bool cmp(par prvi, par drugi){
     if(prvi.first != drugi.first)
        return prvi.first > drugi.first;
     return prvi.second < drugi.second;
}

int main(){
    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%d %d", &cord[i].X, &cord[i].Y);
    }

    sort(cord, cord + n, cmp);

    for(int i = 0; i < n; i++){
        val[i] = cord[i].Y - cord[i].X;
        mapa[val[i]]++;
        pos[val[i]].push_back(i);
    }

    for(int i = 0; i < n; i++){
        scanf("%d", &w[i]);
        mapa2[w[i]]++;
    }

    for(int i = 0; i < n; i++){
        if(mapa2[w[i]] == mapa[w[i]]) continue;
        printf("NO\n");
        return 0;
    }

    printf("YES\n");
    for(int i = 0; i < n; i++){
        int tmp = w[i];
        int br = *(pos[tmp].begin());
        pos[tmp].erase(pos[tmp].begin());
        printf("%d %d", cord[br].X, cord[br].Y);
        if(i != n - 1) printf("\n");
    }

    return 0;
}


n = int(raw_input())
l = []
s = "YES"
for i in range(0,n):
	l.append([])
	one,two,three = raw_input().split()
	l[i].append(one)
	l[i].append(two)
	l[i].append(three)

res = [0,0,0]
for i in range(0,len(l)):
	for j in range(0,3):
		res[j]+=int(l[i][j])
for i in range(0,3):
	print res[i]
	if(res[i] != 0):
		s = "NO"
print s


n = int(raw_input())
l = []
s = "YES"
for i in range(0,n):
	l.append([])
	one,two,three = raw_input().split()
	l[i].append(one)
	l[i].append(two)
	l[i].append(three)

res = [0,0,0]
for i in range(0,len(l[i])-1):
	for j in range(0,3):
		res[j]+=int(l[i][j])
for i in range(0,3):
	if(res[i] != 0):
		s = "NO"
print s


n = int(raw_input())
l = []
s = "YES"
for i in range(0,n):
	l.append([])
	for j in range(0, 3):
		l[i].append(int(raw_input()))

res = [0,0,0]
for i in range(0,len(l[i])-1):
	for j in range(0,3):
		res[j]+=l[i][j]
for i in range(0,3):
	if(res[i] != 0):
		s = "NO"
print s


n = int(raw_input())
l = []
s = "YES"
for i in range(0,n):
	l.append([])
	one,two,three = raw_input().split()
	l[i].append(one)
	l[i].append(two)
	l[i].append(three)

res = [0,0,0]
for i in range(0,len(l)):
	for j in range(0,3):
		res[j]+=int(l[i][j])
for i in range(0,3):
	if(res[i] != 0):
		s = "NO"
print s


a = b = c = 0
for i in xrange(input()):
	abc = map(int, raw_input().split())
	a += abc[0]
	b += abc[1]
	c += abc[2]

if a+b+c:
	print "NO"
else:
	print "YES"


a = b = c = 0
for i in xrange(input()):
	abc = map(int, raw_input().split())
	a += abc[0]
	b += abc[1]
	c += abc[2]

if a and b and c:
	print "NO"
else:
	print "YES"


a = b = c = 0
for i in xrange(input()):
	abc = map(int, raw_input().split())
	a += abc[0]
	b += abc[1]
	c += abc[2]

if a or b or c:
	print "NO"
else:
	print "YES"


#http://codeforces.com/problemset/problem/69/A

n = int(raw_input())

xi = 0
yi = 0
zi = 0

for i in range(n):
    values = raw_input().split(" ")
    xi += int(values[0])
    yi += int(values[1])
    zi += int(values[2])

result = (xi + yi + zi)

if (result == 0):
    print "YES"
else:
    print "NO"


#http://codeforces.com/problemset/problem/69/A

n = int(raw_input())

xi = 0
yi = 0
zi = 0

for i in range(n):
    values = raw_input().split(" ")
    xi += int(values[0])
    yi += int(values[1])
    zi += int(values[2])

if (xi == 0 and y1 == 0 and zi == 0):
    print "YES"
else:
    print "NO"


#http://codeforces.com/problemset/problem/69/A

n = int(raw_input())

xi = 0
yi = 0
zi = 0

for i in range(n):
    values = raw_input().split(" ")
    xi += int(values[0])
    yi += int(values[1])
    zi += int(values[2])

if (xi == 0 and yi == 0 and zi == 0):
    print "YES"
else:
    print "NO"


n = input()
sum = 0
while n>0:
    sum = input() + input() + input()
    n-=1
if sum == 0:
    print "YES"
else:
    print "NO"


n = input()
sumx = 0
sumy = 0
sumz = 0
while n>0:
    line = raw_input().split()
    sumx += int(line[0])
    sumy += int(line[1])
    sumz += int(line[2])
    n-=1
if sumx == 0 and sumy == 0 and sumz == 0:
    print "YES"
else:
    print "NO"


n = input()
sum = 0
while n>0:
    sum += input() + input() + input()
    n-=1
if sum == 0:
    print "YES"
else:
    print "NO"


n = input()
sum = 0
while n>0:
    sum = input() + input() + input()
    n -= 1
if sum == 0:
    print "YES"
else:
    "NO"


n = input()
sum = 0
while n>=0:
    sum = input() + input() + input()
if sum == 0:
    print "YES"
else:
    "NO"


n = input()
sum = 0
while n>0:
    line = raw_input().split(' ')
    for l in line:
        sum += int(l)
    n-=1
if sum == 0:
    print "YES"
else:
    print "NO"


N = input()
sums = [0, 0, 0]

for i in range(N):
    fs = map(int, raw_input().split())
    sums = [sum + f for (sum, f) in zip(sums, fs)]

no = reduce(lambda a, b: a & b, sums)
print 'NO' if no else 'YES'


N = input()
sums = [0, 0, 0]

for i in range(N):
    fs = map(int, input().split())
    sums = [sum + f for (sum, f) in zip(sums, fs)]

no = reduce(lambda a, b: a & b, sums)

print 'NO' if no else 'YES'


N = input()
sums = [0, 0, 0]

for i in range(N):
    fs = map(int, raw_input().split())
    sums = [sum + f for (sum, f) in zip(sums, fs)]

no = reduce(lambda a, b: a or b, sums)
print 'NO' if no else 'YES'


def retrieve_input():
    n = int(raw_input())
    force = []
    for i in xrange(n):
        force.append([int(x) for x in raw_input().split()])
    return [n, force]

def yp(data):
    n = data[0]
    force = data[1]
    fsum = 0
    for x in xrange(n):
        fsum = fsum + sum(k for k in data[1] [x])
    if fsum == 0:
        return 'YES'
    else:
        return 'NO'

def main():
    data = retrieve_input()
    print yp(data)

if __name__ == '__main__':
    main()


def retrieve_force_qty():
    qty_of_forces = int(raw_input())
    return qty_of_forces

def retrieve_force_vector():
    force_vector = [int(x) for x in raw_input().split()]
    yield force_vector

def check_for_equilibrium(xsum,ysum,zsum):
    if xsum == ysum == zsum == 0:
        return 'YES'
    else:
        return 'NO'

def main():
    qty_of_forces = retrieve_force_qty()
    xsum, ysum, zsum = 0,0,0
    for __ in xrange(qty_of_forces):
        force_vector = retrieve_force_vector().next()
        xsum += force_vector[0]
        ysum += force_vector[1]
        zsum += force_vector[2]
    print check_for_equilibrium(xsum,ysum,zsum)

if __name__ == '__main__':
    main()


import numpy as np

def retrieve_input():
    n = int(raw_input())
    force = []
    for i in xrange(n):
        force.append([int(x) for x in raw_input().split()])
    return [n, force]

def yp(data):
    n = data[0]
    force = np.array(data[1])
    sumvec = np.sum(force, axis=0)
    i = 0
    for x in sumvec:
        if x == 0:
            i +=1
        if i == 3:
            return 'YES'
    return 'NO'

def main():
    data = retrieve_input()
    #data = [3, [[0, 2, -2], [1, -1, 3], [-3, 0, 0]]]
    #data = [3, [[3, -1, 7], [-5, 2, -4], [2, -1, -3]]]
    #print data
    print yp(data)

if __name__ == '__main__':
    main()


def retrieve_input():
    n = int(raw_input())
    force = []
    for i in xrange(n):
        force.append([int(x) for x in raw_input().split()])
    return [n, force]

def yp(data):
    n = data[0]
    force = data[1]
    count, equil = 0, 0
    for num in xrange(3):
        for i in xrange(n):
            count += force [i][num]
        if count == 0:
            equil += 1
    if equil >= 3:
        return 'YES'
    else: return 'NO'

def main():
    data = retrieve_input()
    #data = [3, [[0, 2, -2], [1, -1, 3], [-3, 0, 0]]]
    #data = [3, [[3, -1, 7], [-5, 2, -4], [2, -1, -3]]]
    #print data
    print yp(data)

if __name__ == '__main__':
    main()


import sys

def main():
	count=int(sys.stdin.readline())
	result=0
	for i in range(count):
		team=(sys.stdin.readline()).split(' ')
		suma=0
		for i in range(len(team)):
			suma+=int(team[i])
		result+=suma
	if result!=0:
		print 'NO'
	else:
		print 'YES'

if __name__ == '__main__':
	main()


import sys

def main():
	count=int(sys.stdin.readline())
	first=[]
	second=[]
	third=[]
	for i in range(count):
		team=(sys.stdin.readline()).split(' ')
		first.append(int(team[0]))
		second.append(int(team[1]))
		third.append(int(team[2]))
	if sum(first)!=0 or sum(second)!=0 or sum(third)!=0:
		print 'NO'
	else:
		print 'YES'

if __name__ == '__main__':
	main()


import sys

def main():
	count=int(sys.stdin.readline())
	i=0
	for i in range(count):
		array=(sys.stdin.readline()).split(' ')
		del array[len(array)-1]
		suma = 0
		for j in range(len(array)):
			suma+=int(array[j])
		i+=suma
	if i==0:
		print 'YES'
	else:
		print 'NO'

if __name__=='__main__':
	main()


n = int(raw_input())
for i in range(n):
   temp_x, temp_y, temp_z = map(int,raw_input().split())
   a = x.append(temp_x)
   b = y.append(temp_y)
   c = z.append(temp_z)
if (sum(a)==0 and sum(b)==0 and sum(c)==0):
    print "YES"
else:
    print  "NO"


n = int(raw_input())
x, y, z = list(),list(),list()
for i in range(n):
    temp_x, temp_y, temp_z = map(int,raw_input().split())
    x.append(temp_x)
    y.append(temp_y)
    z.append(temp_z)
if (sum(x)==0 and sum(y)==0 and sum(z)==0):
    print "YES"
else:
    print  "NO"


n = int(raw_input())
x, y, z = list(),list(),list()
for i in range(n):
   temp_x, temp_y, temp_z = map(int,raw_input().split())
   a = x.append(temp_x)
   b = y.append(temp_y)
   c = z.append(temp_z)
if (sum(a)==0 and sum(b)==0 and sum(c)==0):
    print "YES"
else:
    print  "NO"


import sys
n=input()
a=[[int(i) for i in raw_input().split()]for j in range(n)]
for i in range(3):
    c=0
    for j in range(n):
        c+=a[j][i]
    if(c!=0):
        print "NO"
        sys.exit()
print "YES"


import sys
n=input()
a=[[int(i) for i in raw_input().split()]for j in range(n)]
for i in range(n):
    c=0
    for j in range(n):
        c+=a[j][i]
    if(c!=0):
        print "NO"
        sys.exit()
print "YES"


n = int(raw_input())

s = 0

for i in range(0, n):
    ss = raw_input().split(" ")
    s += int(ss[0]) + int(ss[1]) + int(ss[2])

if s == 0:
    print "YES"
else:
    print "NO"


n = int(raw_input())

sx = 0
sy = 0
sz = 0

for i in range(0, n):
    ss = raw_input().split(" ")
    sx += int(ss[0])
    sy += int(ss[1])
    sz += int(ss[2])

print "YES" if sx == 0 and sy == 0 and sz == 0 else "NO"


n = int(raw_input())

sx = 0
sy = 0
sz = 0

for i in range(0, n):
    ss = raw_input().split(" ")
    sx += int(ss[0])
    sy += int(ss[1])
    sz += int(ss[2])

if sx == 0 and sy == 0 and sz == 0:
    print "YES"
else:
    print "NO"


#coding: utf-8
n = int(raw_input())

soma = 0
x = 0
y = 0
z = 0

for i in range(n):
   	coordinates = raw_input().split(" ")
	x += int(coordinates[0])
	y += int(coordinates[1])
	z += int(coordinates[2])

if (x == 0 and y == 0 and z == 0):
    print "YES"
else:
    print "NO"


#coding: utf-8
n = int(raw_input())

soma = 0

for i in range(n):
    coordinates = raw_input().split(" ")
    for j in range(len(coordinates)):
        soma += int(coordinates[j])

if (soma == 0):
    print "YES"
else:
    print "NO"


#coding: utf-8
m = int(raw_input())

soma = 0
x = 0
y = 0
z = 0

for i in range(m):
   	coordinates = raw_input().split(" ")
	x += int(coordinates[0])
	y += int(coordinates[1])
	z += int(coordinates[2])

if (x == 0 and y == 0 and z == 0):
    print "YES"
else:
    print "NO"


import math
#coding: utf-8
n = int(raw_input())
lista = []
soma = 0
count = 0
j = 0
for i in range(n):
	leitura = map(int,raw_input().split())
	lista.append(leitura)
for i in range(n):
	soma += lista[i][j]
	count +=1
	if soma != 0 and count == 3:
		print "NÃO"
		break
	elif soma == 0  and count == 3:
		j+=1
		count = 0
if soma == 0:
	print "SIM"


import math
#coding: utf-8
n = int(raw_input())
lista = []
soma = 0
count = 0
j = 0
for i in range(n):
	leitura = map(int,raw_input().split())
	lista.append(leitura)
for i in range(n):
	soma += lista[i][j]
	count +=1
	if soma != 0 and count == n:
		print "NO"
		break
	elif soma == 0  and count == n:
		j+=1
		count = 0
if soma == 0:
	print "YES"


import math
#coding: utf-8
n = int(raw_input())
lista = []
soma = 0
count = 0
j = 0
for i in range(n):
	leitura = map(int,raw_input().split())
	lista.append(leitura)
for i in range(n):
	soma += lista[i][j]
	count +=1
	if soma != 0 and count == 3:
		print "NO"
		break
	elif soma == 0  and count == 3:
		j+=1
		count = 0
if soma == 0:
	print "YES"


n = int(raw_input())
lst = []
s = 0
for i in range (n):
    lst = raw_input().split()
    for item in lst:
        s+=int(item)
if s == 0:
    print "YES"
else:
    print "NO"


n = int(raw_input())
lst = []
s = 0
for i in range (n):
    lst.append(raw_input().split())
lst1 = [val for sub in lst for val in sub]
for item in lst1:
    s+=int(item)
if s == 0:
    print "YES"
else:
    print "NO"


n = int(raw_input())
lst = [0]*n*3
s = 0
flag = 0
for i in range(n):
    tmp = raw_input().split()
    for j in range(len(tmp)):
        lst[j%3] += int(tmp[j])
for i in range(3):
    if lst[i] != 0:
        flag = 1

if flag == 0:
    print "YES"
else:
    print "NO"


def sum(l):
    sum1 = 0
    for i in l:
        sum1+=i
    if sum1==0:
        return 1
    else:
        return 0
t = int(raw_input())
l0,l1,l2 = [],[],[]
for h in range(t):
    l = [int(x) for x in raw_input().split()]
    l0.append(l[0])
    l1.append(l[1])
    l2.append(l[2])
if sum(l0)==1 and sum(l1)==1 and sum(l2)==1:
    print "Yes"
else:
    print "No"


def sum(l):
    sum1 = 0
    for i in l:
        sum1+=i
    if sum1==0:
        return 1
    else:
        return 0
t = int(raw_input())
l0,l1,l2 = [],[],[]
for h in range(t):
    l = [int(x) for x in raw_input().split()]
    l0.append(l[0])
    l1.append(l[1])
    l2.append(l[2])
if sum(l0)==1 and sum(l1)==1 and sum(l2)==1:
    print "YES"
else:
    print "NO"


n = int(raw_input())
l = [int(x) for x in raw_input().split()]
m = [int(x) for x in raw_input().split()]
p = [int(x) for x in raw_input().split()]
if l[0]+m[0]+p[0] == 0 and l[1]+m[1]+p[1]==0 and l[2]+m[2]+p[2]==0:
    print "Yes"
else:
    print "No"


n = int(raw_input())
F_tot = [0,0,0]

#Get the data
for i in range(0,n):
	F_Vec = raw_input().split(' ')
	for j in range(0, 3):
		F_tot[j] += int(F_Vec[j])

print "YES" if F_tot[0] == 0 and F_tot[1] == 0 and F_tot[2] == 0 else "NO"


n = int(raw_input())
F_tot = [0,0,0]

#Get the data
for i in range(0,n):
	F_Vec = raw_input().split(' ')
	for j in range(0, 3):
		F_tot[j] = F_Vec[j]

print "YES" if F_tot[0] == 0 and F_tot[1] == 0 and F_tot[2] == 0 else "NO"


n = int(raw_input())
F_tot = [0,0,0]

#Get the data
for i in range(0,n):
	F_Vec = raw_input().split(' ')
	for j in range(0, 3):
		F_tot[j] += F_Vec[j]

print "YES" if F_tot[0] == 0 and F_tot[1] == 0 and F_tot[2] == 0 else "NO"


n = int(raw_input())
F_tot = [0,0,0]

#Get the data
a = [[0]*3]*n
for i in range(0,n):
	F_Vec = raw_input().split(' ')
	for j in range(0, 3):
		a[i][j] = int(F_Vec[j])
#Process the data

for j in range(0, 3):
	for i in range(0,n):
		F_tot[j] += a[i][j]
print "YES" if F_tot[0] == F_tot[1] == F_tot[2] == 0 else "NO"


vector_num = int(raw_input())

r = [ 0, 0, 0 ]

while vector_num:
	ri = map(int, raw_input().split())

	r[0] += ri[0]
	r[2] += ri[1]
	r[1] += ri[2]

	vector_num -= 1

print 'NO' if r[0] == r[1] == r[2] == 0 else 'YES'


vector_num = int(raw_input())

r = [ 0, 0, 0 ]

while vector_num:
    ri = map(int, raw_input().split())

    r[0] += ri[0]
    r[2] += ri[1]
    r[1] += ri[2]

    vector_num -= 1

print 'NO' if sum(r) else 'YES'


vector_num = int(raw_input())

r = [ 0, 0, 0 ]

while vector_num:
    ri = map(int, raw_input().split())

    r[0] += ri[0]
    r[2] += ri[1]
    r[1] += ri[2]

    vector_num -= 1

print 'YES' if r[0] == r[1] == r[2] == 0 else 'NO'


n = int(raw_input())

i = 0
x = []
y = []
z = []
while i < n:
    c = [int(a) for a in raw_input().split()]
    x.append(c[0])
    y.append(c[1])
    z.append(c[2])
    i += 1

if sum(x) == 0 and sum(y) == 0 and sum(z) == 0:
    print "YES"
else:
    print "NO"


n = int(raw_input())

i = 0
x = y = z = []
while i < n:
    c = [int(a) for a in raw_input().split()]
    x.append(c[0])
    y.append(c[1])
    z.append(c[2])

if x.sum() == 0 and y.sum() == 0 and z.sum() == 0:
    print "YES"
else:
    print "NO"


n = int(raw_input())

i = 0
x = y = z = []
while i < n:
    c = [int(a) for a in raw_input().split()]
    x.append(c[0])
    y.append(c[1])
    z.append(c[2])
    i += 1

if sum(x) == 0 and sum(y) == 0 and sum(z) == 0:
    print "YES"
else:
    print "NO"


print ['YES','NO'][sum([sum(map(int,raw_input().split())) for i in range(0,input())])>0]


x=y=z=0
for i in range(0,input()):
    l = map(int,raw_input().split())
    x += l[0];y += l[1]; z += l[2]
print ['NO','YES'][x==0 and y ==0 and z==0]


__author__ = 'kh9107'
print ['NO','YES'][sum([sum(map(int,raw_input().split())) for i in range(0,input())])==0]


def solve(vectors):
    x_count =y_count=z_count=0
    for vector in vectors:
        x_count+=vector[0]
        y_count +=vector[1]
        z_count+=vector[2]
    if(x_count==y_count==z_count==0):
        return "YES"
    else:
        return "NO"
if __name__ == "__main__":
    cases =int(input())
    vectors=[]
    for x in range(cases):
        vectors=map(int,raw_input().split(" "))
        vectors.append(vectors)
    print(solve(vectors))


def Solve(vectors):
    x_count =y_count=z_count=0
    for vector in vectors:
        x_count+=vector[0]
        y_count +=vector[1]
        z_count+=vector[2]
    if(x_count==y_count==z_count==0):
        return "YES"
    else:
        return "NO"
if __name__ == "__main__":
    cases =int(input())
    vectors=[]
    for x in range(cases):
        vectors=map(int,raw_input().split(" "))
        vectors.append(vectors)
    print(solve(vectors))


def solve(vectors):
    x_count =y_count=z_count=0
    for vector in vectors:
        x_count+=vector[0]
        y_count +=vector[1]
        z_count+=vector[2]
    if(x_count==y_count==z_count==0):
        return "YES"
    else:
        return "NO"
if __name__ == "__main__":
    cases =int(input())
    vectors=[]
    for x in range(cases):
        vector=map(int,raw_input().split(" "))
        vectors.append(vector)
    print(solve(vectors))


n=int(input("n = "))
if(n<1):
    n=1
elif(n>100):
    n=100
xsum=0
ysum=0
zsum=0
for i in range(n):
    v=raw_input('v = ')
    v=map(int,v.split())
    if abs(v[0])>100:
        v[0]=100
    if abs(v[1])>100:
        v[1]=100
    if abs(v[2])>100:
        v[2]=100
    xsum+=v[0]
    ysum+=v[1]
    zsum+=v[2]
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import numpy as np
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    x=input('x = ')
    y=input('y = ')
    z=input('z = ')
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import pdb
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    v=raw_input('v = ')
    v=v.split()
    v=map(int,v)
    x=v[0]
    y=v[1]
    z=v[2]
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import numpy as np
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    x=input('x = ')
    y=input('y = ')
    z=input('z = ')
    x=int(x)
    y=int(y)
    z=int(z)
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import pdb
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    v=raw_input('v = ')
    v=v.split()
    v=map(int,v)
    x=v[0]
    y=v[1]
    z=v[2]

    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import pdb
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    v=raw_input('v = ')
    v=v.split()
    x=float(v[0])
    x=int(x)
    y=float(v[1])
    y=int(y)
    z=float(v[2])
    z=int(z)
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import numpy as np
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    x=input('x = ')
    y=input('y = ')
    z=input('z = ')
    z=int(z)
    y=int(y)
    x=int(x)
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


import numpy as np
n=input("n = ")
xsum=0
ysum=0
zsum=0
for i in range(n):
    x=input('x = ')
    y=input('y = ')
    z=input('z = ')
    y=int(y)
    x=int(x)
    z=int(z)
    xsum+=x
    ysum+=y
    zsum+=z
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


xsum=0
ysum=0
zsum=0
n=int(input(""))
if(n<1):
    n=1
elif(n>100):
    n=100
for i in range(n):
    v=raw_input('')
    v=map(int,v.split())
    if abs(v[0])>100:
        v[0]=100
    if abs(v[1])>100:
        v[1]=100
    if abs(v[2])>100:
        v[2]=100
    xsum+=v[0]
    ysum+=v[1]
    zsum+=v[2]
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


xsum=0
ysum=0
zsum=0
n=int(input("n = "))
if(n<1):
    n=1
elif(n>100):
    n=100
for i in range(n):
    v=raw_input('v = ')
    v=map(int,v.split())
    if abs(v[0])>100:
        v[0]=100
    if abs(v[1])>100:
        v[1]=100
    if abs(v[2])>100:
        v[2]=100
    xsum+=v[0]
    ysum+=v[1]
    zsum+=v[2]
if(xsum==0 and ysum==0 and zsum==0):
    print('YES')
else:
    print('NO')


n = input()
print 'NO' if any(map(sum, zip(*[map(int, raw_input().split()) for i in range(n)]) )) else 'YES'


n = input()
print 'NO' if any(map(sum, zip(map(int, raw_input().split()) for i in range(n)]) ) else 'YES'


n = input()
print 'NO' if any(map(sum, zip([map(int, raw_input().split()) for i in range(n)]) )) else 'YES'


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 23 15:00:24 2017

"""

times = raw_input()
vec = []
for i in range(int(times)):
    check = raw_input()
    vec.append(check.split())
#print vec
x = []
y = []
z = []
for item in vec:
    x.append(item[0])
    y.append(item[1])
    z.append(item[2])

#print x
x = map(int, x)
y = map(int, y)
z = map(int, z)
if sum(x) == 0 and sum(y) == 0 and sum(z) == 0:
    print "YES"

else:
    print "NO"


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 23 15:00:24 2017

"""

times = raw_input()
vec = []
for i in range(int(times)):
    check = raw_input()
    check = check.split()
    for a in check:
        vec.append(int(a))

if sum([vec[0], vec[3], vec[6]]) == 0 and sum([vec[1], vec[4], vec[7]]) == 0 and sum([vec[2], vec[4], vec[7]]) == 0:
    print "YES"

else:
    print "NO"


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 23 15:00:24 2017

"""

times = raw_input()
vec = []
for i in range(int(times)):
    check = raw_input()
    check = check.split()
    for a in check:
        vec.append(int(a))

if sum(vec) == 0:
    print "YES"
else:
    print "NO"


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 23 15:00:24 2017

"""

times = raw_input()
vec = []
for i in range(int(times)):
    check = raw_input()
    check = check.split()
    for a in check:
        vec.append(int(a))

if sum([vec[0], vec[3], vec[6]]) == 0 and sum([vec[1], vec[4], vec[7]]) == 0 and sum([vec[2], vec[5], vec[8]]) == 0:
    print "YES"

else:
    print "NO"


n = int(raw_input())
s = 0
for i in range(0, n):
  a = map(int, raw_input().split())
  c = 0
  for x in a:
    c+=x
  s+=c
if s == 0:
  print "YES"
else:
  print "NO"


n = int(raw_input())
x,y,z = 0,0,0
for i in range(0, n):
  a,b,c = map(int, raw_input().split())
  x+=a
  y+=b
  z+=c
if x == 0 and y==0 and z==0:
  print "YES"
else:
  print "NO"


n = int(raw_input())
s = 0
c = 0
for i in range(0, n):
  a = map(int, raw_input().split())
  for x in a:
    c+=x
  s+=c
if s == 0:
  print "YES"
else:
  print "NO"


n = int(raw_input())
s = 0
c = 0
for i in range(0, n):
  a = map(int, raw_input().split())
  for x in a:
    c+=x
  s+=x
if s == 0:
  print "YES"
else:
  print "NO"


a =input()
sum=0
for i in range(a):
    x,y,z= map(int,raw_input().split())
    sum = sum + x+y+z
#print x, y, z
#print sum

if sum == 0:
    print "YES"
else:
    print "NO"


a = raw_input()
b = 0
c = 0
d = 0
for index in range(int(a)):
    line = raw_input()
    b = b + int(line.split(' ')[0])
    c = c + int(line.split(' ')[1])
    d = d + int(line.split(' ')[2])

if b == 0 & c == 0 & d == 0:
    print 'YES'
else:
    print 'NO'


a = input()
#print a
sum = 0
for i in range(0,a):
    b = map(int,raw_input().split())
#    print b
    for j in b:
        sum += j
    print sum


a =input()
sum=0
q=0
w=0
e=0
for i in range(a):
    x,y,z= map(int,raw_input().split())
    x=x+q
    y=y+w
    z=e+z

if x == 0 and y == 0 and z == 0:
    print "YES"
else:
    print "NO"


a = input()
#print a
sum = 0
for i in range(0,a):
    b = map(int,raw_input().split())
#    print b
    for j in b:
        sum += j
    #print sum
if sum == 0:
    print "YES"
else:
    print "NO"


a =input()
sum=0
c = 0
d=0
e=0
list=[]
for i in range(a):
    list.append(raw_input().split())
    c=int(list[i][0])+c
    d = int(list[i][1])+d
    e = int(list[i][2])+e
#print c,d,e
if c==0 and d==0 and e==0:
    print "YES"
else:
    print "NO"


l = [raw_input().split(' ') for i in range(input()) ]
a = sum(int(l[i][0]) for i in range(len(l)))
b = sum(int(l[i][1]) for i in range(len(l)))
c = sum(int(l[i][2]) for i in range(len(l)))
ans = "NO"
if (a==b==c==0):
	ans = "YES"
print ans


l = [raw_input().split(' ') for i in range(input()) ]
a = sum(int(l[i][0]) for i in range(len(l)))
b = sum(int(l[i][1]) for i in range(len(l)))
c = sum(int(l[i][2]) for i in range(len(l)))
print "YNEOS"[(a!=0 and b!=0 and c!=0)::2]


n = input()
a = 0
for i in range(n):
	l = map(int,raw_input().split(' '))
	a += sum(l)
print "YNEOS"[a != 0::2]


n=input()
res=0
for i in range(n):
    res+=sum(map(int,raw_input().split()))
if(res==0):
    print "YES"
else:
    print "NO"


n=input()
x=0
y=0
z=0
for i in range(n):
    x1,y1,z1=(map(int,raw_input().split()))
    x+=x1
    y+=y1
    z+=z1
if((x+y+z)==0):
    print "YES"
else:
    print "NO"


n=input()
x=0
y=0
z=0
for i in range(n):
    x1,y1,z1=(map(int,raw_input().split()))
    x+=x1
    y+=y1
    z+=z1
if((x|y|z)==0):
    print "YES"
else:
    print "NO"


n=int(raw_input())
x=y=z=0
for i in range(n):
    x1,y1,z1=map(int,raw_input().split())
    x+=x1;y+=y1;z+=z1
print ["NO","YES"][x+y+z==0]


n=int(raw_input())
x=y=z=0
for i in range(n):
    x1,y1,z1=map(int,raw_input().split())
    x+=x1;y+=y1;z+=z1
print ["NO","YES"][x==y==z]


n=int(raw_input())
x=y=z=0
for i in range(n):
    x1,y1,z1=map(int,raw_input().split())
    x+=x1;y+=y1;z+=z1
print ["NO","YES"][x==0 and y==0 and z==0]


using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApplication
{
    public class Program
    {
        // availabilities =  1 1 1 1 1
        // days_to_prepare = 5
        private static int get_last_session_day(
            int[] availabilities,
            int[] days_to_prepare)
        {
            var days_count = availabilities.Length; // days_count = 5
            var exams_count = days_to_prepare.Length; // exams_count = 1

            // what if days_count == 0 -> return -1;
            // what if exams_count == 0 -> return 0?

            var min_last_day = exams_count; // min_last_day = 1
            var max_last_day = days_count; // max_last_day = 5

            if (is_possible_to_close(min_last_day - 1, availabilities, days_to_prepare)) {
                return min_last_day;
            }

            if (!is_possible_to_close(max_last_day - 1, availabilities, days_to_prepare)) {
                return -1;
            }

            while (true) {
                if (max_last_day - min_last_day == 1) {
                    return max_last_day;
                }

                var middle_last_day = min_last_day + (max_last_day - min_last_day) / 2; // middle_last_day = 5

                if (is_possible_to_close(middle_last_day - 1, availabilities, days_to_prepare)) {
                    max_last_day = middle_last_day;
                }
                else {
                    min_last_day = middle_last_day;
                }
            }
        }

        // last_day_index = 4
        // availabilities = 1 1 1 1 1
        // days_to_prepare = 5
        private static bool is_possible_to_close(
            int last_day_index,
            int[] availabilities,
            int[] days_to_prepare)
        {
            var exams_count = days_to_prepare.Length; // exams_count = 1
            var passed_exams = new HashSet<int>(); // passed_exams = { 1 }

            var required_days_to_prepare = 0L;

            for (var current_day_index = last_day_index; current_day_index >= 0; --current_day_index) { // current_day_index = 4
                var current_exam_number = availabilities[current_day_index]; // current_exam_number = 1

                if (current_exam_number == 0) {
                    required_days_to_prepare = Math.Max(required_days_to_prepare - 1, 0);
                }
                else {
                    if (passed_exams.Contains(current_exam_number)) {
                        required_days_to_prepare = Math.Max(required_days_to_prepare - 1, 0);
                    }
                    else {
                        var current_exam_index = current_exam_number - 1;   // current_exam_index = 0
                        required_days_to_prepare += days_to_prepare[current_exam_index]; // += 5

                        // register exam as passed
                        passed_exams.Add(current_exam_number);

                        // with current day being spent on passing exam - no rest days to register
                    }
                }
            }

            return (passed_exams.Count == exams_count)
                && (required_days_to_prepare == 0);
        }

        public static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split(' ');
            var exams_count = int.Parse(tokens[0]);
            var days_count = int.Parse(tokens[1]);

            var availabilities = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            var days_to_prepare = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            Console.WriteLine(get_last_session_day(availabilities, days_to_prepare));
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApplication
{
    public class Program
    {
        // availabilities =  1 1 1 1 1
        // days_to_prepare = 5
        private static int get_last_session_day(
            int[] availabilities,
            int[] days_to_prepare)
        {
            var days_count = availabilities.Length; // days_count = 5
            var exams_count = days_to_prepare.Length; // exams_count = 1

            // what if days_count == 0 -> return -1;
            // what if exams_count == 0 -> return 0?

            var min_last_day = exams_count; // min_last_day = 1
            var max_last_day = days_count; // max_last_day = 5

            if (is_possible_to_close(min_last_day - 1, availabilities, days_to_prepare)) {
                return min_last_day;
            }

            if (!is_possible_to_close(max_last_day - 1, availabilities, days_to_prepare)) {
                return -1;
            }

            while (true) {
                if (max_last_day - min_last_day == 1) {
                    return max_last_day;
                }

                var middle_last_day = min_last_day + (max_last_day - min_last_day) / 2; // middle_last_day = 5

                if (is_possible_to_close(middle_last_day - 1, availabilities, days_to_prepare)) {
                    max_last_day = middle_last_day;
                }
                else {
                    min_last_day = middle_last_day;
                }
            }
        }

        // last_day_index = 4
        // availabilities = 1 1 1 1 1
        // days_to_prepare = 5
        private static bool is_possible_to_close(
            int last_day_index,
            int[] availabilities,
            int[] days_to_prepare)
        {
            var exams_count = days_to_prepare.Length; // exams_count = 1
            var passed_exams = new HashSet<int>(); // passed_exams = { 1 }

            var required_days_to_prepare = 0; //  required_days_to_prepare = 5
            var rest_days_to_prepare = 0; // rest_days_to_prepare = 4

            for (var current_day_index = last_day_index; current_day_index >= 0; --current_day_index) { // current_day_index = 4
                var current_exam_number = availabilities[current_day_index]; // current_exam_number = 1

                if (current_exam_number == 0) {
                    ++rest_days_to_prepare;
                }
                else {
                    if (passed_exams.Contains(current_exam_number)) {
                        ++rest_days_to_prepare;
                    }
                    else {
                        var current_exam_index = current_exam_number - 1;   // current_exam_index = 0
                        required_days_to_prepare += days_to_prepare[current_exam_index]; // += 5

                        // register exam as passed
                        passed_exams.Add(current_exam_number);

                        // with current day being spent on passing exam - no rest days to register
                    }
                }
            }

            return (passed_exams.Count == exams_count)
                && (rest_days_to_prepare >= required_days_to_prepare);
        }

        public static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split(' ');
            var exams_count = int.Parse(tokens[0]);
            var days_count = int.Parse(tokens[1]);

            var availabilities = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            var days_to_prepare = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            Console.WriteLine(get_last_session_day(availabilities, days_to_prepare));
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApplication
{
    public class Program
    {
        // availabilities =  1 1 1 1 1
        // days_to_prepare = 5
        private static int get_last_session_day(
            int[] availabilities,
            int[] days_to_prepare)
        {
            var days_count = availabilities.Length; // days_count = 5
            var exams_count = days_to_prepare.Length; // exams_count = 1

            // what if days_count == 0 -> return -1;
            // what if exams_count == 0 -> return 0?

            var min_last_day = exams_count; // min_last_day = 1
            var max_last_day = days_count; // max_last_day = 5

            if (is_possible_to_close(min_last_day - 1, availabilities, days_to_prepare)) {
                return min_last_day;
            }

            if (!is_possible_to_close(max_last_day - 1, availabilities, days_to_prepare)) {
                return -1;
            }

            while (true) {
                if (max_last_day - min_last_day == 1) {
                    return max_last_day;
                }

                var middle_last_day = min_last_day + (max_last_day - min_last_day) / 2; // middle_last_day = 5

                if (is_possible_to_close(middle_last_day - 1, availabilities, days_to_prepare)) {
                    max_last_day = middle_last_day;
                }
                else {
                    min_last_day = middle_last_day;
                }
            }
        }

        // last_day_index = 4
        // availabilities = 1 1 1 1 1
        // days_to_prepare = 5
        private static bool is_possible_to_close(
            int last_day_index,
            int[] availabilities,
            int[] days_to_prepare)
        {
            var exams_count = days_to_prepare.Length; // exams_count = 1
            var passed_exams = new HashSet<int>(); // passed_exams = { 1 }

            var required_days_to_prepare = 0L; //  required_days_to_prepare = 5
            var rest_days_to_prepare = 0L; // rest_days_to_prepare = 4

            for (var current_day_index = last_day_index; current_day_index >= 0; --current_day_index) { // current_day_index = 4
                var current_exam_number = availabilities[current_day_index]; // current_exam_number = 1

                if (current_exam_number == 0) {
                    ++rest_days_to_prepare;
                }
                else {
                    if (passed_exams.Contains(current_exam_number)) {
                        ++rest_days_to_prepare;
                    }
                    else {
                        var current_exam_index = current_exam_number - 1;   // current_exam_index = 0
                        required_days_to_prepare += days_to_prepare[current_exam_index]; // += 5

                        // register exam as passed
                        passed_exams.Add(current_exam_number);

                        // with current day being spent on passing exam - no rest days to register
                    }
                }
            }

            return (passed_exams.Count == exams_count)
                && (rest_days_to_prepare >= required_days_to_prepare);
        }

        public static void Main(string[] args)
        {
            var tokens = Console.ReadLine().Split(' ');
            var exams_count = int.Parse(tokens[0]);
            var days_count = int.Parse(tokens[1]);

            var availabilities = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            var days_to_prepare = Console.ReadLine().Split(' ')
                .Select(int.Parse)
                .ToArray();

            Console.WriteLine(get_last_session_day(availabilities, days_to_prepare));
        }
    }
}


using System;
using System.IO;
using System.Linq;
using System.Text;

namespace Exams
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);
        private static int[] nn;
        private static long[] mm;

        private static void Main(string[] args)
        {
            int n = Next();
            int m = Next();

            nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next() - 1;
            }

            mm = new long[m];
            for (int i = 0; i < m; i++)
            {
                mm[i] = Next();
            }

            long l = m + mm.Sum() - 1;
            long r = n - 1;

            while (l < r)
            {
                long mid = (l + r)/2;

                if (Check(mid))
                    r = mid;
                else
                {
                    l = mid + 1;
                }
            }

            if (Check(r))
                writer.WriteLine(r + 1);
            else
            {
                writer.WriteLine("-1");
            }

            writer.Flush();
        }

        private static bool Check(long index)
        {
            var f = new bool[mm.Length];

            long free = 0;
            int count = 0;
            for (long i = index; i >= 0; i--)
            {
                if (nn[i] == -1 || f[nn[i]])
                {
                    if (free > 0)
                        free--;
                }
                else
                {
                    count++;
                    f[nn[i]] = true;
                    free += mm[nn[i]];
                }
            }
            return count == mm.Length && free == 0;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m, n, selected;
        static int[] a, d;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            n = int.Parse(input1[0]); m = int.Parse(input1[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            d = new int[n];
            for (int i = 0; i < n; i++) d[i] = int.Parse(input2[i]);
            string[] input3 = Console.ReadLine().Split(' ');
            a = new int[m];
            for (int i = 0; i < m; i++) a[i] = int.Parse(input3[i]);

            Select(0);
            int day = 0;
            bool[] completed = new bool[m];
            for (int i = 0; i < m; i++) completed[i] = false;

            for (; day < n; day++)
            {
                if (a[selected] == 0)
                    Select(day);

                if (d[day] == 0 && a[selected] > 0)
                {
                    a[selected]--;
                }
                else
                {
                    if ((d[day] == 0 && a[selected] == 0) || a[d[day] - 1] == 0)
                    {
                        if (d[day] == 0) completed[d[day]] = true;
                        else completed[d[day] - 1] = true;
                        bool allCompleted = true;
                        for (int i = 0; i < m; i++)
                        {
                            if (!completed[i]) allCompleted = false;
                        }
                        if (allCompleted) break;
                    }
                    else
                    {
                        a[selected]--;
                    }
                }

                /*Console.WriteLine("day: " + (day + 1));
                Console.WriteLine("a: " + string.Join(" ", a));
                Console.WriteLine("completed: " + string.Join(" ", completed));*/
            }

            if (day == n)
            {
                bool allCompleted = true;
                for (int i = 0; i < m; i++)
                {
                    if (!completed[i]) allCompleted = false;
                }

                if (allCompleted)
                {
                    Console.WriteLine(n);
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
            else
            {
                Console.WriteLine(day + 1);
            }
            //Console.ReadLine();
        }

        static void Select(int day)
        {
            List<int> toSelect = new List<int>();
            toSelect.Add(0);
            for (int i = 1; i < m; i++)
            {
                if (a[toSelect[0]] < a[i])
                {
                    toSelect.Clear();
                    toSelect.Add(i);
                }
                else if (a[toSelect[0]] == a[i])
                {
                    toSelect.Add(i);
                }
            }
            if (toSelect.Count == 1)
            {
                selected = toSelect[0];
            }
            else
            {
                Dictionary<int, int> timeToExam = new Dictionary<int, int>(toSelect.Count);
                for (int i = 0; i < toSelect.Count; i++)
                {
                    for (int j = day; j < n; j++)
                    {
                        if (d[j] == toSelect[i] + 1)
                        {
                            timeToExam.Add(toSelect[i], j - day);
                            break;
                        }
                    }
                }

                int min = timeToExam.Min(x => x.Value);
                selected = timeToExam.First(x => x.Value == min).Key;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m, n, selected;
        static int[] a, d;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            n = int.Parse(input1[0]); m = int.Parse(input1[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            d = new int[n];
            for (int i = 0; i < n; i++) d[i] = int.Parse(input2[i]);
            string[] input3 = Console.ReadLine().Split(' ');
            a = new int[m];
            for (int i = 0; i < m; i++) a[i] = int.Parse(input3[i]);

            Select(0);
            int day = 0;
            bool[] completed = new bool[m];
            for (int i = 0; i < m; i++) completed[i] = false;

            for (; day < n; day++)
            {
                if (a[selected] == 0)
                    Select(day);

                if (d[day] == 0)
                {
                    a[selected]--;
                }
                else
                {
                    if (a[d[day] - 1] == 0)
                    {
                        completed[d[day] - 1] = true;
                        bool allCompleted = true;
                        for (int i = 0; i < m; i++)
                        {
                            if (!completed[i]) allCompleted = false;
                        }
                        if (allCompleted) break;
                    }
                    else
                    {
                        a[selected]--;
                    }
                }

                Console.WriteLine("day: " + (day + 1));
                Console.WriteLine("a: " + string.Join(" ", a));
                Console.WriteLine("completed: " + string.Join(" ", completed));
            }

            if (day == n)
            {
                bool allCompleted = true;
                for (int i = 0; i < m; i++)
                {
                    if (!completed[i]) allCompleted = false;
                }

                if (allCompleted)
                {
                    Console.WriteLine(n);
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
            else
            {
                Console.WriteLine(day + 1);
            }
            //Console.ReadLine();
        }

        static void Select(int day)
        {
            List<int> toSelect = new List<int>();
            toSelect.Add(0);
            for (int i = 1; i < m; i++)
            {
                if (a[toSelect[0]] < a[i])
                {
                    toSelect.Clear();
                    toSelect.Add(i);
                }
                else if (a[toSelect[0]] == a[i])
                {
                    toSelect.Add(i);
                }
            }
            if (toSelect.Count == 1)
            {
                selected = toSelect[0];
            }
            else
            {
                Dictionary<int, int> timeToExam = new Dictionary<int, int>(toSelect.Count);
                for (int i = 0; i < toSelect.Count; i++)
                {
                    for (int j = day; j < n; j++)
                    {
                        if (d[j] == toSelect[i] + 1)
                        {
                            timeToExam.Add(toSelect[i], j - day);
                            break;
                        }
                    }
                }

                int min = timeToExam.Min(x => x.Value);
                selected = timeToExam.First(x => x.Value == min).Key;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]); m = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            int[] d = new int[n + 1];
            for (int i = 1; i <= n; i++) d[i] = int.Parse(input2[i - 1]);

            string[] input3 = Console.ReadLine().Split(' ');
            int sum = 0;
            for (int i = 0; i < m; i++)
            {
                int val = int.Parse(input3[i]);
                sum += val + 1;
            }

            if (sum > n)
            {
                Console.WriteLine("-1");
            }
            else
            {
                int i;
                for (i = sum; i <= n; i++)
                {
                    if (d[i] != 0 && Ok(i, d))
                    {
                        Console.WriteLine(i);
                        //Console.ReadLine();
                        return;
                    }
                }
                if (i > n)
                {
                    Console.WriteLine("-1");
                }
            }
            //Console.ReadLine();
        }

        static bool Ok(int i, int[] d)
        {
            bool[] ok = new bool[m + 1];
            for (int j = 1; j <= m; j++) ok[j] = false;

            for (int j = 2; j <= i; j++)
            {
                ok[d[j]] = true;
            }
            bool result = true;
            for (int j = 1; j <= m; j++)
            {
                if (!ok[j])
                {
                    result = false;
                    break;
                }
            }
            return result;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]); m = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            int[] d = new int[n + 1];
            for (int i = 1; i <= n; i++) d[i] = int.Parse(input2[i - 1]);

            string[] input3 = Console.ReadLine().Split(' ');
            int sum = 0;
            for (int i = 0; i < m; i++)
            {
                int val = int.Parse(input3[i]);
                sum += val + 1;
            }

            if (sum > n)
            {
                Console.WriteLine("-1");
            }
            else
            {
                int i;
                for (i = sum; i <= n; i++)
                {
                    if (d[i] != 0 && Ok(i, d))
                    {
                        Console.WriteLine(i);
                        //Console.ReadLine();
                        return;
                    }
                }
                if (i > n)
                {
                    Console.WriteLine("-1");
                }
            }
        }

        static bool Ok(int i, int[] d)
        {
            bool[] ok = new bool[m + 1];
            for (int j = 1; j <= m; j++) ok[j] = false;

            for (int j = 1; j <= i; j++)
            {
                ok[d[j]] = true;
            }
            bool result = true;
            for (int j = 1; j <= m; j++)
            {
                if (!ok[j])
                {
                    result = false;
                    break;
                }
            }
            return result;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m, n, selected;
        static int[] a, d;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            n = int.Parse(input1[0]); m = int.Parse(input1[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            d = new int[n];
            for (int i = 0; i < n; i++) d[i] = int.Parse(input2[i]);
            string[] input3 = Console.ReadLine().Split(' ');
            a = new int[m];
            for (int i = 0; i < m; i++) a[i] = int.Parse(input3[i]);

            Select(0);
            int day = 0;
            bool[] completed = new bool[m];
            for (int i = 0; i < m; i++) completed[i] = false;

            for (; day < n; day++)
            {
                if (a[selected] == 0)
                    Select(day);

                if (d[day] == 0)
                {
                    a[selected]--;
                }
                else
                {
                    if (a[d[day] - 1] == 0)
                    {
                        completed[d[day] - 1] = true;
                        bool allCompleted = true;
                        for (int i = 0; i < m; i++)
                        {
                            if (!completed[i]) allCompleted = false;
                        }
                        if (allCompleted) break;
                    }
                    else
                    {
                        a[selected]--;
                    }
                }

                /*Console.WriteLine("day: " + (day + 1));
                Console.WriteLine("a: " + string.Join(" ", a));
                Console.WriteLine("completed: " + string.Join(" ", completed));*/
            }

            if (day == n)
            {
                bool allCompleted = true;
                for (int i = 0; i < m; i++)
                {
                    if (!completed[i]) allCompleted = false;
                }

                if (allCompleted)
                {
                    Console.WriteLine(n);
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
            else
            {
                Console.WriteLine(day + 1);
            }
            //Console.ReadLine();
        }

        static void Select(int day)
        {
            List<int> toSelect = new List<int>();
            toSelect.Add(0);
            for (int i = 1; i < m; i++)
            {
                if (a[toSelect[0]] < a[i])
                {
                    toSelect.Clear();
                    toSelect.Add(i);
                }
                else if (a[toSelect[0]] == a[i])
                {
                    toSelect.Add(i);
                }
            }
            if (toSelect.Count == 1)
            {
                selected = toSelect[0];
            }
            else
            {
                Dictionary<int, int> timeToExam = new Dictionary<int, int>(toSelect.Count);
                for (int i = 0; i < toSelect.Count; i++)
                {
                    for (int j = day; j < n; j++)
                    {
                        if (d[j] == toSelect[i] + 1)
                        {
                            timeToExam.Add(toSelect[i], j - day);
                            break;
                        }
                    }
                }

                int min = timeToExam.Min(x => x.Value);
                selected = timeToExam.First(x => x.Value == min).Key;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static int m, n, selected;
        static int[] a, d;
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            n = int.Parse(input1[0]); m = int.Parse(input1[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            d = new int[n];
            for (int i = 0; i < n; i++) d[i] = int.Parse(input2[i]);
            string[] input3 = Console.ReadLine().Split(' ');
            a = new int[m];
            for (int i = 0; i < m; i++) a[i] = int.Parse(input3[i]);

            Select(0);
            int day = 0;
            bool[] completed = new bool[m];
            for (int i = 0; i < m; i++) completed[i] = false;

            for (; day < n; day++)
            {
                if (a[selected] == 0)
                    Select(day);

                if (d[day] == 0 && a[selected] > 0)
                {
                    a[selected]--;
                }
                else if (d[day] > 0)
                {
                    if (a[d[day] - 1] == 0)
                    {
                        completed[d[day] - 1] = true;
                        bool allCompleted = true;
                        for (int i = 0; i < m; i++)
                        {
                            if (!completed[i]) allCompleted = false;
                        }
                        if (allCompleted) break;
                    }
                    else
                    {
                        a[selected]--;
                    }
                }

                /*Console.WriteLine("day: " + (day + 1));
                Console.WriteLine("a: " + string.Join(" ", a));
                Console.WriteLine("completed: " + string.Join(" ", completed));*/
            }

            if (day == n)
            {
                bool allCompleted = true;
                for (int i = 0; i < m; i++)
                {
                    if (!completed[i]) allCompleted = false;
                }

                if (allCompleted)
                {
                    Console.WriteLine(n);
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
            else
            {
                Console.WriteLine(day + 1);
            }
            //Console.ReadLine();
        }

        static void Select(int day)
        {
            List<int> toSelect = new List<int>();
            toSelect.Add(0);
            for (int i = 1; i < m; i++)
            {
                if (a[toSelect[0]] < a[i])
                {
                    toSelect.Clear();
                    toSelect.Add(i);
                }
                else if (a[toSelect[0]] == a[i])
                {
                    toSelect.Add(i);
                }
            }
            if (toSelect.Count == 1)
            {
                selected = toSelect[0];
            }
            else
            {
                Dictionary<int, int> timeToExam = new Dictionary<int, int>(toSelect.Count);
                for (int i = 0; i < toSelect.Count; i++)
                {
                    for (int j = day; j < n; j++)
                    {
                        if (d[j] == toSelect[i] + 1)
                        {
                            timeToExam.Add(toSelect[i], j - day);
                            break;
                        }
                    }
                }

                int min = timeToExam.Min(x => x.Value);
                selected = timeToExam.First(x => x.Value == min).Key;
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _732D
{
    class Program
    {
        static void Main()
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int n = int.Parse(input1[0]), m = int.Parse(input1[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            int[] d = new int[n + 1];
            for (int i = 1; i <= n; i++) d[i] = int.Parse(input2[i - 1]);

            string[] input3 = Console.ReadLine().Split(' ');
            int sum = 0;
            for (int i = 0; i < m; i++)
            {
                int val = int.Parse(input3[i]);
                sum += val + 1;
            }

            if (sum > n)
            {
                Console.WriteLine("-1");
            }
            else
            {
                int i;
                for (i = sum; i <= n; i++)
                {
                    if (d[i] != 0)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
                if (i > n)
                {
                    Console.WriteLine("-1");
                }
            }
        }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }

        object Solve()
        {
            checked
            {
                var n = ReadLong();
                var m = ReadLong();
                var d = ReadLongs();
                var a = ReadLongs();
                if (!Check(d, a, n, m))
                    return -1;
                return BS(1, n, a, d, m);
            }
        }
        public class My
        {
            public long Day;
            public long Subj;
        }

        public long BS(long left, long right, long[] a, long[] d, long m)
        {
            if (right - left == 1)
                return right;
            var half = (right + left) / 2;
            if (Check(d, a, half, m))
                return BS(left, half, a, d, m);
            return BS(half, right, a, d, m);
        }

        public bool Check(long[] d, long[] a, long n, long m)
        {
            var subjLastDay = new long[m];
            for (int i = 0; i < m; i++)
                subjLastDay[i] = -1;
            for (int i = 0; i < n; i++)
                if (d[i] > 0)
                    subjLastDay[d[i] - 1] = i;
            var order = subjLastDay.Select((day, subj) => new My { Day = day, Subj = subj }).OrderBy(x => x.Day).ToArray();
            if (order[0].Day == -1)
                return false;
            var daysUsed = 0L;
            var lastDay = 0L;
            for (int i = 0; i < order.Length; i++)
            {
                if (order[i].Day < a[order[i].Subj] + daysUsed)
                    return false;
                daysUsed += a[order[i].Subj] + 1;
                lastDay = i;
            }
            return true;
        }
    }

    class UnionFind
    {
        private int[] arr;
        private Random r = new Random();
        public UnionFind(int n)
        {
            arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i;
            }
        }

        public int Find(int x)
        {
            if (arr[arr[x]] == arr[x])
                return arr[x];
            var y = Find(arr[x]);
            arr[x] = y;
            return y;
        }

        public void Union(int x, int y)
        {
            var p1 = Find(x);
            var p2 = Find(y);
            if (p1 == p2)
                return;
            if (r.NextDouble() < 0.5)
                arr[p1] = p2;
            else
                arr[p2] = p1;
        }

        public int[][] Enumerate() {
            return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => e.Select(y => y.i).ToArray()).ToArray();
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
}


using System;
using System.Globalization;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Codeforces
{
    class Program : ProgramBase
    {
        private const long commonMod = 1000000007;

        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Solve();
            p.Out(x);
        }

        object Solve()
        {
            checked
            {
                var n = ReadLong();
                var m = ReadLong();
                var d = ReadLongs();
                var a = ReadLongs();
                if (!Check(d, a, n, m))
                    return -1;
                return BS(1, n, a, d, m);
            }
        }
        public class My
        {
            public long Day;
            public long Subj;
        }

        public long BS(long left, long right, long[] a, long[] d, long m)
        {
            if (right - left == 1)
                return right;
            var half = (right + left) / 2;
            if (Check(d, a, half, m))
                return BS(left, half, a, d, m);
            return BS(half, right, a, d, m);
        }

        public bool Check(long[] d, long[] a, long n, long m)
        {
            var subjLastDay = new long[m];
            for (int i = 0; i < m; i++)
                subjLastDay[i] = -1;
            for (int i = 0; i < n; i++)
                if (d[i] > 0)
                    subjLastDay[d[i] - 1] = i;
            var order = subjLastDay.Select((day, subj) => new My { Day = day, Subj = subj }).ToArray();
            if (order[0].Day == -1)
                return false;
            var daysUsed = 0L;
            var lastDay = 0L;
            for (int i = 0; i < order.Length; i++)
            {
                if (order[i].Day + 1 < a[order[i].Subj] + 1+ daysUsed)
                    return false;
                daysUsed += a[order[i].Subj] + 1;
                lastDay = i;
            }
            return true;
        }
    }

    class UnionFind
    {
        private int[] arr;
        private Random r = new Random();
        public UnionFind(int n)
        {
            arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i;
            }
        }

        public int Find(int x)
        {
            if (arr[arr[x]] == arr[x])
                return arr[x];
            var y = Find(arr[x]);
            arr[x] = y;
            return y;
        }

        public void Union(int x, int y)
        {
            var p1 = Find(x);
            var p2 = Find(y);
            if (p1 == p2)
                return;
            if (r.NextDouble() < 0.5)
                arr[p1] = p2;
            else
                arr[p2] = p1;
        }

        public int[][] Enumerate() {
            return arr.Select((x, i) => new { g = Find(x), i }).GroupBy(x => x.g, (k, e) => e.Select(y => y.i).ToArray()).ToArray();
        }
    }

    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        Queue<string> tokens;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (f == null)
                f = string.IsNullOrEmpty(FileName)
                    ? new StreamReader(Console.OpenStandardInput())
                    : new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName);
            return f.ReadLine();
        }

        protected string ReadToken()
        {
            if (tokens == null || tokens.Count == 0)
                tokens = new Queue<string>(Read().Split(' '));
            return tokens.Dequeue();
        }

        protected long ReadLong() { return long.Parse(ReadToken()); }

        protected long[] ReadLongs()
        {
            var s = Read();
            if (s == "")
                return new long[0];
            var tokens = s.Split(' ');
            var result = new long[tokens.Length];
            for (int i = 0; i < tokens.Length; i++)
                result[i] = long.Parse(tokens[i]);
            return result;
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName, r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {

            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func, T defaultValue = default(T))
        {
            T result = defaultValue;
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> s, string d) { return string.Join(d, s.ToArray()); }

        public static string JoinStrings(this IEnumerable<int> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
        public static string JoinStrings(this IEnumerable<long> s, string d) { return s.Select(x => x.ToString()).JoinStrings(d); }
    }
}


using System;
using System.Linq;

public class Class4
{
    public static void Main()
    {
        Solve(new ConsoleInput());
    }

    private static void Solve(IInput input)
    {
        var nm = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var days = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var daysNeeded = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var totalNeededSum = daysNeeded.Sum() + m;

        var flags = new bool[m];
        for (var i = 0; i < n; i++)
        {
            if (days[i] > 0)
            {
                flags[days[i] - 1] = true;
            }
            else
            {
                continue;
            }

            if (flags.All(v => v))
            {
                if (i+1 >= totalNeededSum)
                {
                    Console.WriteLine(i + 1);
                    return;
                }

            }
        }
    }

}

public interface IInput
{
    string ReadLine();
}

public class ConsoleInput : IInput
{
    public string ReadLine()
    {
        return Console.ReadLine();
    }
}

public abstract class AbstractMockInput : IInput
{
    protected virtual string[] lines { get; }

    private int currentLine = 0;

    public string ReadLine()
    {
        if (this.currentLine >= this.lines.Length)
        {
            return string.Empty;
        }

        var res = this.lines[this.currentLine];
        this.currentLine++;
        return res;
    }
}

public class MockInput1 : AbstractMockInput
{
    protected override string[] lines => new[] { "7 2", "0 1 0 2 1 0 2", "2 1" };
}

public class MockInput2 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 0 0" }; // 0
}

public class MockInput3 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 1 1" }; // 0
}

public class MockInput4 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 0 1000000000000000000" }; // 99999..
}

public class MockInput5 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 1000000000000000000 999999999999999999" }; // 0
}

public class MockInput6 : AbstractMockInput
{
    protected override string[] lines => new[] { "0 1 0" }; // 0
}


using System;
using System.Linq;

public class Class4
{
    public static void Main()
    {
        Solve(new ConsoleInput());
    }

    private static void Solve(IInput input)
    {
        var nm = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var days = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var daysNeeded = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var totalNeededSum = daysNeeded.Sum() + m;

        var flags = new bool[m];
        for (var i = 0; i < n; i++)
        {
            if (days[i] > 0)
            {
                flags[days[i] - 1] = true;
            }
            else
            {
                continue;
            }

            if (flags.All(v => v))
            {
                if (i+1 >= totalNeededSum)
                {
                    Console.WriteLine(i + 1);
                    return;
                }

            }
        }

        Console.WriteLine("-1");
    }

}

public interface IInput
{
    string ReadLine();
}

public class ConsoleInput : IInput
{
    public string ReadLine()
    {
        return Console.ReadLine();
    }
}

public abstract class AbstractMockInput : IInput
{
    protected virtual string[] lines { get; }

    private int currentLine = 0;

    public string ReadLine()
    {
        if (this.currentLine >= this.lines.Length)
        {
            return string.Empty;
        }

        var res = this.lines[this.currentLine];
        this.currentLine++;
        return res;
    }
}

public class MockInput1 : AbstractMockInput
{
    protected override string[] lines => new[] { "7 2", "0 1 0 2 1 0 2", "2 1" };
}

public class MockInput2 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 0 0" }; // 0
}

public class MockInput3 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 1 1" }; // 0
}

public class MockInput4 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 0 1000000000000000000" }; // 99999..
}

public class MockInput5 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 1000000000000000000 999999999999999999" }; // 0
}

public class MockInput6 : AbstractMockInput
{
    protected override string[] lines => new[] { "0 1 0" }; // 0
}


using System;
using System.Linq;

public class Class4
{
    public static void Main()
    {
        Solve(new ConsoleInput());
    }

    private static void Solve(IInput input)
    {
        var nm = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var days = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var daysNeeded = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var totalNeededSum = daysNeeded.Sum() + m;

        var counts = new int[m];

        for (int i = 0; i < n; i++)
        {
            if (days[i] > 0)
            {
                counts[days[i] - 1] += daysNeeded[days[i] - 1];
            }
            else
            {
                continue;
            }

            if (counts.Sum() >= totalNeededSum)
            {
                Console.WriteLine(i + 1);
                return;
            }
        }

        Console.WriteLine("-1");
    }

}

public interface IInput
{
    string ReadLine();
}

public class ConsoleInput : IInput
{
    public string ReadLine()
    {
        return Console.ReadLine();
    }
}

public abstract class AbstractMockInput : IInput
{
    protected virtual string[] lines { get; }

    private int currentLine = 0;

    public string ReadLine()
    {
        if (this.currentLine >= this.lines.Length)
        {
            return string.Empty;
        }

        var res = this.lines[this.currentLine];
        this.currentLine++;
        return res;
    }
}

public class MockInput1 : AbstractMockInput
{
    protected override string[] lines => new[] { "7 2", "0 1 0 2 1 0 2", "2 1" };
}

public class MockInput2 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 0 0" }; // 0
}

public class MockInput3 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 1 1" }; // 0
}

public class MockInput4 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 0 1000000000000000000" }; // 99999..
}

public class MockInput5 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 1000000000000000000 999999999999999999" }; // 0
}

public class MockInput6 : AbstractMockInput
{
    protected override string[] lines => new[] { "0 1 0" }; // 0
}


using System;
using System.Linq;

public class Class4
{
    public static void Main()
    {
        Solve(new ConsoleInput());
    }

    private static void Solve(IInput input)
    {
        var nm = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var days = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var daysNeeded = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var totalNeededSum = daysNeeded.Sum() + m;

        var flags = new bool[m];
        var found = 0;

        for (int i = 0; i < n; i++)
        {
            var day = days[i];

            if (day > 0
                && i + 1 > daysNeeded[day - 1]
                && !flags[day - 1])
            {
                flags[day - 1] = true;
                found++;
            }

            if (found == m && i + 1 >= totalNeededSum)
            {
                Console.WriteLine(i + 1);
                return;
            }
        }

        Console.WriteLine("-1");
    }

}

public interface IInput
{
    string ReadLine();
}

public class ConsoleInput : IInput
{
    public string ReadLine()
    {
        return Console.ReadLine();
    }
}

public abstract class AbstractMockInput : IInput
{
    protected virtual string[] lines { get; }

    private int currentLine = 0;

    public string ReadLine()
    {
        if (this.currentLine >= this.lines.Length)
        {
            return string.Empty;
        }

        var res = this.lines[this.currentLine];
        this.currentLine++;
        return res;
    }
}

public class MockInput1 : AbstractMockInput
{
    protected override string[] lines => new[] { "7 2", "0 1 0 2 1 0 2", "2 1" };
}

public class MockInput2 : AbstractMockInput
{
    protected override string[] lines => new[] { "10 3", "0 0 1 2 3 0 2 0 1 2", "1 1 4" };
}

public class MockInput3 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 1 1" }; // 0
}

public class MockInput4 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 0 1000000000000000000" }; // 99999..
}

public class MockInput5 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 1000000000000000000 999999999999999999" }; // 0
}

public class MockInput6 : AbstractMockInput
{
    protected override string[] lines => new[] { "0 1 0" }; // 0
}


using System;
using System.Linq;

public class Class4
{
    public static void Main()
    {
        Solve(new ConsoleInput());
    }

    private static void Solve(IInput input)
    {
        var nm = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        var days = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var daysNeeded = input.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var totalNeededSum = daysNeeded.Sum() + m;

        var flags = new bool[m];
        var found = 0;

        for (int i = 0; i < n; i++)
        {
            var day = days[i];

            if (day > 0
                && i + 1 >= daysNeeded[day - 1]
                && !flags[day - 1])
            {
                flags[day - 1] = true;
                found++;
            }

            if (found == m && i + 1 >= totalNeededSum)
            {
                Console.WriteLine(i + 1);
                return;
            }
        }

        Console.WriteLine("-1");
    }

}

public interface IInput
{
    string ReadLine();
}

public class ConsoleInput : IInput
{
    public string ReadLine()
    {
        return Console.ReadLine();
    }
}

public abstract class AbstractMockInput : IInput
{
    protected virtual string[] lines { get; }

    private int currentLine = 0;

    public string ReadLine()
    {
        if (this.currentLine >= this.lines.Length)
        {
            return string.Empty;
        }

        var res = this.lines[this.currentLine];
        this.currentLine++;
        return res;
    }
}

public class MockInput1 : AbstractMockInput
{
    protected override string[] lines => new[] { "7 2", "0 1 0 2 1 0 2", "2 1" };
}

public class MockInput2 : AbstractMockInput
{
    protected override string[] lines => new[] { "10 3", "0 0 1 2 3 0 2 0 1 2", "1 1 4" };
}

public class MockInput3 : AbstractMockInput
{
    protected override string[] lines => new[] { "1 1 1" }; // 0
}

public class MockInput4 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 0 1000000000000000000" }; // 99999..
}

public class MockInput5 : AbstractMockInput
{
    protected override string[] lines => new[] { "1000000000000000000 1000000000000000000 999999999999999999" }; // 0
}

public class MockInput6 : AbstractMockInput
{
    protected override string[] lines => new[] { "0 1 0" }; // 0
}