Problem:
Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.

If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1).
Note that he cannot stay at his place.
Determine whether he can carry out his plan.

Constraints

1 ≤ N ≤ 10^5

0 ≤ x_i ≤ 10^5

0 ≤ y_i ≤ 10^5

1 ≤ t_i ≤ 10^5

t_i < t_{i+1} (1 ≤ i ≤ N-1)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
t_1 x_1 y_1
t_2 x_2 y_2
:
t_N x_N y_N

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.

Sample Input 1

2
3 1 2
6 1 1

Sample Output 1

Yes

For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).

Sample Input 2

1
2 100 100

Sample Output 2

No

It is impossible to be at (100,100) two seconds after being at (0,0).

Sample Input 3

2
5 1 1
100 1 1

Sample Output 3

No

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

// can be applied to string type
#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define YES cout<<"YES"<<End
#define NO cout<<"NO"<<End
#define Yes cout<<"Yes"<<End
#define No cout<<"No"<<End
template<typename T>
void Outln(const string &sep, const T &val) { cout << val << End; }
template<typename T, typename... Args>
void Outln(const string &sep, const T &val, Args... args) {
    cout << val << sep;
	Outln(sep, std::forward<Args>(args)...);
}
template<typename T>
void Outln(const char &ch, const T &val) { cout << val << End; }
template<typename T, typename... Args>
void Outln(const char &ch, const T &val, Args... args) {
	cout << val << ch;
	Outln(ch, std::forward<Args>(args)...);
}
// container output function
template<typename T>
inline void OutN(T x) {
	size_t i, len = x.size() - 1;

	for (i = 0; i < len; i++) cout << x[i] << " ";
	cout << x[len] << '\n';
}
// array output function
template<typename T>
inline void OutaN(T x[], const size_t &n) {
	size_t i, len = n - 1;

    for (i = 0; i < len; i++) cout << x[i] << " ";
    cout << x[len] << '\n';
}
// iterator output function
template<typename T>
inline void Outit(T x) {
	auto end = x.end();

	end--;

	for (auto it = x.begin(); it != end; it++) cout << *it << " ";
	cout << *end << '\n';
}
template<typename T>
void Debug(const T &val) { cerr << val << End; }
template<typename T, typename... Args>
void Debug(const T &val, Args... args) {
    cerr << val << ' ';
	Debug(std::forward<Args>(args)...);
}

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

// can be applied to string type
#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
// array sorters
#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));
#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())

#define pf push_front
#define pb push_back
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define mt make_tuple
#define a first
#define b second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

inline bool isSame(const string &a, const string &b) { return a.compare(b) == 0; }
inline bool isLess(const string &a, const string &b) { return a.compare(b) < 0; }
inline bool isGreater(const string &a, const string &b) { return a.compare(b) > 0; }
inline string Str(const char &ch, const int &n) { return string(n, ch); }
inline string Str(const int &n, const char &ch) { return string(n, ch); }
vector<string> getStrLine() {
	vector<string> v;
	string str;

	getline(cin, str);

	istringstream iss(str);

	for (string word; iss >> word;) v.push_back(word);

	return v;
}

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;
inline double rad2deg(const double &rad) { return rad * (180.0 / PI); }
inline double deg2rad(const double &deg) { return deg * (PI / 180.0); }

/*** ATCODER, CODECHEF and TOPCODER ***/

// -2147483648 <= INT <= 2147483647
// -9223372036854775808 <= LONG <= 9223372036854775807
// -9223372036854775808 <= LLONG <= 9223372036854775807

/*** END ***/

/*** CODEFORCES ***/

// -2147483648 <= INT <= 2147483647
// -2147483648 <= LONG <= 2147483647
// -9223372036854775808 <= LLONG <= 9223372036854775807

/*** END ***/

// [C-f5] 'reload
// [C-f6] 'getready
// [C-f7] 'copy
// [C-f8] 'compile
// [C-f9] 'make

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
 
    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	int t, x, y;
	int prevT, prevX, prevY;
	int dist;

	prevT = prevX = prevY = 0;

	while (n--) {
		cin >> t >> x >> y;

		dist = Abs(x - prevX) + Abs(y - prevY);

		if (dist == 0 && (t - prevT) % 2 == 0) {
			continue;
		} else if (dist <= t - prevT && (t - prevT) % dist == 0) {
			continue;
		} else {
			No;

			return 0;
		}

		prevT = t;
		prevX = x;
		prevY = y;
	}

	Yes;
	
	return 0;
}