#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000000;
map<pair<int, int>, int> cache;
map<pair<int, int>, bool> is_cached;
int query(int x, int y){
    if(is_cached[{x, y}]) return cache[{x, y}];
    printf("0 %d %d\n", x, y);
    fflush(stdout);
    int d;
    scanf("%d", &d);
    is_cached[{x, y}] = true;
    if(d == -1) exit(0);
    cache[{x, y}] = d;
    return d;
}
vector<int> queries;
void solve(int lo, int hi){
    //printf("Solving %d - %d\n", lo, hi);
    int md = (lo + hi) / 2;
    int q = query(md, md);
    if(q == (md - lo)){
        if(md + q < hi){
            int p = query(md + q, md + q);
            if(p == 0) {
                //printf("Inserting %d\n", p);
                queries.push_back(p);
            }
        }
        return;
    }
    int pos1 = md - q;
    int p = query(pos1, pos1);
    int found = pos1;
    if(p) found = md + q;
    //printf("Inserting %d\n", found);
    queries.push_back(found);
    solve(lo, found);
    solve(found, hi);
}
int find_none(vector<int> a){
    if(a[0] != -MAX) return -MAX;
    int i = 1;
    for(; i < a.size(); i++){
        if(a[i] != a[i - 1] + 1) break;
    }
    return a[i - 1] + 1;
}
vector<int> vertical, horizontal;
void resolve(vector<int> pts){
    int none = find_none(pts);
    for(auto p : pts){
        int q1 = query(none, p);
        if(q1 == 0) horizontal.push_back(p);
        int q2 = query(p, none);
        if(q2 == 0) vertical.push_back(p);
    }
    printf("1 %d %d\n", vertical.size(), horizontal.size());
    for(auto x : vertical) printf("%d ", x); printf("\n");
    for(auto y : horizontal) printf("%d ", y); printf("\n");
}
int main(){
    int lo = query(-MAX, -MAX) - MAX;
    int hi = MAX - query(MAX, MAX);
    queries.push_back(lo);
    queries.push_back(hi);
    solve(lo, hi);
    sort(queries.begin(), queries.end());
    queries.resize(unique(queries.begin(), queries.end()) - queries.begin());
    resolve(queries);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000000;
map<pair<int, int>, int> cache;
map<pair<int, int>, bool> is_cached;
const int MAXN = 100010;
int x[MAXN], y[MAXN];
int n, m;
int my_impl(int x, int y){
    int mn = 3 * MAX;
    for(int i = 0; i < n; i++) mn = min(mn, abs(::x[i] - x));
    for(int i = 0; i < m; i++) mn = min(mn, abs(::y[i] - y));
    return mn;
}
int query(int x, int y){
    //return my_impl(x, y);
    if(is_cached[{x, y}]) return cache[{x, y}];
    printf("0 %d %d\n", x, y);
    fflush(stdout);
    int d;
    scanf("%d", &d);
    is_cached[{x, y}] = true;
    if(d == -1) exit(0);
    cache[{x, y}] = d;
    return d;
}
vector<int> queries;
int mydiv(int a){
    if(a >= 0) return a / 2;
    return (a - 1) / 2;
}
void solve(int lo, int hi){
    //printf("%d %d\n", lo, hi);
    //printf("Solving %d ---- %d\n", lo, hi);
    int md = mydiv(lo + hi);
    int q = query(md, md);
    //printf("Queried %d and got %d\n", md, q);
    if(q == (md - lo)){
        if(md + q < hi){
            int p = query(md + q, md + q);
            if(p == 0) {
                //printf("Inserting %d\n", md + q);
                queries.push_back(md + q);
            }
        }
        return;
    }
    int pos1 = md - q;
    int p = query(pos1, pos1);
    int found = pos1;
    if(p) found = md + q;
    printf("Inserting %d\n", found);
    queries.push_back(found);
    solve(lo, found);
    solve(found, hi);
}
int find_none(vector<int> a){
    if(a[0] != -MAX) return -MAX;
    int i = 1;
    for(; i < a.size(); i++){
        if(a[i] != a[i - 1] + 1) break;
    }
    return a[i - 1] + 1;
}
vector<int> vertical, horizontal;
void resolve(vector<int> pts){
    int none = find_none(pts);
    for(auto p : pts){
        int q1 = query(none, p);
        if(q1 == 0) horizontal.push_back(p);
        int q2 = query(p, none);
        if(q2 == 0) vertical.push_back(p);
    }
    printf("1 %d %d\n", vertical.size(), horizontal.size());
    for(auto x : vertical) printf("%d ", x); printf("\n");
    for(auto y : horizontal) printf("%d ", y); printf("\n");
}
void problem(){
    int lo = query(-MAX, -MAX) - MAX;
    int hi = MAX - query(MAX, MAX);
    queries.push_back(lo);
    queries.push_back(hi);
    solve(lo, hi);
    sort(queries.begin(), queries.end());
    queries.resize(unique(queries.begin(), queries.end()) - queries.begin());
    resolve(queries);
}
int main(){
    //scanf("%d %d", &n, &m);
    //for(int i = 0; i < n; i++) scanf("%d", &x[i]);
    //for(int i = 0; i < m; i++) scanf("%d", &y[i]);
    problem();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {

    long long cnt1, cnt2, x, y;

    cin >> cnt1 >> cnt2 >> x >> y;
    long long both = 0;

    for (long long i = 1;; ++i) {
        if (i % x != 0 && i % y != 0) {
            ++both;
        }
        if (i % x != 0 && i % y == 0) {
            --cnt1;
        } else if (i % x == 0 && i % y != 0) {
            --cnt2;
        }

        if (cnt1 - both <= 0) {
            long long next = both - cnt1;
            if (cnt2 - next <= 0) {
                cout << i << "\n";
                return 0;
            }
        }

    }

    return 0;
}


#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    long long a,b,c,T1,T2,p,q,X,Y,flag=0,v=1,temp;
    cin>>T1>>T2>>X>>Y;
    while(flag==0)
    {
     a=v/X;
     b=v/Y;
     c=v/(X*Y);
     p=b-c;
     q=a-c;
     temp=v-c-(p+q);
     if(p>=T1)
     {
      if(q+temp>=T2)
      flag=1;
     }
     else if( flag!=1 && q>=T2)
     {
     if(p+temp>=T1)
      flag=1;

     }
     else
     {
      if(flag!=1 && p+temp>=T1)
      {
       temp=temp-(T1-p);
       if(q+temp>=T2)
       flag=1;
       }
      if(flag!=1 && q+temp>=T2)
      {
       temp=temp-(T2-q);
       if(p+temp>=T1)
       flag=1;
       }

       }
       v++;
       }
      if(flag==1)
      cout<<v-1;

    return 0;
}


#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ulng;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<ll, ll> PLL;
typedef pair<ll, int> PLI;
typedef pair<ld, ld> PDD;
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define forn(i,n) for(int i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
const double EPS = 1e-6;
const int INF = 1000*1000*1000;
const long double INFf = 1000000000000.00000000;
const char CINF = 102;
const ll LINF = INF * 1ll * INF;
const ld PI = 3.1415926535897932384626433832795;
ll gcd(ll a,ll b){return a?gcd(b%a,a):b;}

const int nmax = 1010;
const int mod = 1000000007;
int cnt1,cnt2,x,y;
bool check(int mid){
int z = mid/x,zz = mid/y,zzz=mid/(x*y);

if((mid-z)>=cnt1 && (mid-zz)>=cnt2 && (mid-zzz)>=(cnt1+cnt2))return true;
return false;
}
void bsearch(){
int a,b,mid;
a = 1;
b = 1000000000;
while(a < b -1){
mid = (a+b)>>1;

if(check(mid))
b = mid;
    else
a = mid;
}
if(check(a)){cout << a <<  endl;}
else cout << b << endl;
}
int main()
{
cin >> cnt1 >> cnt2 >> x >> y;
bsearch();
}


#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    int a,b,c,T1,T2,p,q,X,Y,flag=0,v=1,temp;
    cin>>T1>>T2>>X>>Y;
    while(flag==0)
    {
     a=v/X;
     b=v/Y;
     c=v/(X*Y);
     p=b-c;
     q=a-c;
     temp=v-c-(p+q);
     if(p>=T1)
     {
      if(q+temp>=T2)
      flag=1;
     }
     else if( flag!=1 && q>=T2)
     {
     if(p+temp>=T1)
      flag=1;

     }
     else
     {
      if(flag!=1 && p+temp>=T1)
      {
       temp=temp-(T1-p);
       if(q+temp>=T2)
       flag=1;
       }
      if(flag!=1 && q+temp>=T2)
      {
       temp=temp-(T2-q);
       if(p+temp>=T1)
       flag=1;
       }

       }
       v++;
       }
      if(flag==1)
      cout<<v-1;

    return 0;
}


#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int q, tmp;
	cin >> q;
	unordered_multiset<int> query;
	for (int i = 0; i < q; i++)
	{
		cin >> tmp;
		query.insert(tmp);
	}
	unsigned long long a = 0, b = 0;
	for (int i = 0; i < n; i++)
	{
		q = query.count(arr[i]);
		a += (i + 1) * q;
		b += (n - i) * q;
	}
	cout << a << " " << b;
	return 0;
}


#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int q, tmp;
	cin >> q;
	unordered_multiset<int> query;
	for (int i = 0; i < q; i++)
	{
		cin >> tmp;
		query.insert(tmp);
	}
	unsigned long long a = 0, b = 0;
	for (int i = 0; i < n; i++)
	{
		q = query.count(arr[i]);
		a += (i + 1) * q;
		b += (n - i) * q;
	}
	printf("%d %d", a, b);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

#define debug(a) cout<<"#a = "<<a<<endl;
int main()
{
	int n,x,Sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		Sum+=x;
	}
	if(n<=4){
		string s="";
		int dem=0;
		int t=100;

		while(t--){
			s+="x";
			for(int i=1;i<=n;i++)
				{
					s+="o"; t--;
				}
		}
		for(int i=Sum;i<=Sum+4;i++)
		{
			if(s[i]=='o') dem++;
		}
		cout<<dem<<endl;
		//return 0;
	}

	else{
		if(Sum%(n+1)==1) cout<<min(5,n)<<endl;
		else if(Sum%(n+1)==0) cout<<min(4,n)<<endl;
		else cout<<min(4,n-1)<<endl;
	}

}


#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;
	int a[100], sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int q = 0;
	for (int j = 1; j <= 5; j++)
		if ((sum + j - 1) % (n + 1) != 0)
			q++;
	cout << q;
	return 0;
}


#include<iostream>
#include<string>
#include<vector>
using namespace std;

#define vi vector<int>
#define pb push_back
#define forn(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define forn1(i,a,b) for(int i = (int)a; i >= (int)b; i--)
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >

int n;
int ff[1000002];
int xx[10];

int f ( int x )
{
    if ( x == 0 ) return 0;
    else x = x%9;
    if ( x == 0 ) return 9;
    return x;
}

int main()
{
    long long cnt = 0,res = 0;
    cin >> n;
    forn(i,0,1000001) ff[i] = f(i);
    forn(j,1,10)
    {
       if ( n >= j ) xx[j] = ( n - j )/9 + 1;
       else xx[j] = 0;
    }
    //forn(j,1,10) cout << xx[j] <<" ";
    //cout << endl;
    forn(i,1,n+1)
    {
       cnt = 0;
       forn(j,1,10)
       {
          int d = ff[ff[i]*ff[j]];
          cnt += xx[d];
       }
       cnt *= (n/9);
       forn(j,1,n%9+1)
       {
          int d = ff[i*j];
          cnt += xx[d];
       }
       cnt -= n/i;
      // cout << cnt << endl;
       res += cnt;
    }
    cout << res;
    return 0;
}


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

using namespace std;

long d(long x)
{
	long sum=0;
	while(x>0)
	{
		sum+=x%10;
		x/=10;
	}
	if (sum<=9) return sum;
	return d(sum);
}

long D[1000001]={0};
vector < vector <int> > v(10,vector <int>());

int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	long n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		D[i]=d(i);
		v[D[i]].push_back(i);
	}
	/*for(int i=1;i<=9;i++)
	{
		for(int j=0;j<v[i].size();j++)
			printf("%d	",v[i][j]);
		printf("\n");
	}*/
	long long ans1=0;
//	for(int i=1;i<=9;i++)
//	{
		long long f=0;
		for(int j=1;j<=9;j++)
		{
			if (v[j].size()==0) continue;
			for(int t=1;t<=9;t++)
			{
				if (v[t].size()==0) continue;
//				if (d(j*t)==i)
//				{
					int i=d(j*t);
					f+=((long long)v[j].size())*((long long)v[t].size())*((long long)v[i].size());
					for(int r=0;r<v[j].size();r++)
					{
						/*long l=0,R=v[i].size()-1;
						while(l<=R)
						{
							long M=(l+R)/2;
							if (v[i][M]*v[j][r]<=n&&(M==v[i].size()-1||v[i][M]*v[j][r]>n)) break;
							if (v[i][M]*v[j][r]<=n) l=M+1;
							else r=M-1;
						}
						long M=(l+R)/2;
						if (v[i][M]*v[j][r]<=n&&(M==v[i].size()-1||v[i][M]*v[j][r]>n)) f-=(M+1);
						*///if (v[i].size()>0) f-=(n/v[j][r])/t;
						vector <int>::iterator low=v[t].begin()/*lower_bound(v[i].begin(),v[i].end(),v[i][0])*/,up=upper_bound(v[t].begin(),v[t].end(),n/v[j][r]);
						f-=long long(up-low);
					}
//				}
			//	if (i==1&&j==1)
			}
		}
//		f*=n-v[i].size();
		ans1+=f;
//	}
	printf("%I64d\n",ans1);
/*	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if (d(d(i)*d(j))==1)
					printf("%d	%d\n",i,j);*/
/*	long last=0;
//	for(n=1;n<=100;n++)
//	{
	ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int t=1;t<=n;t++)
			{
				if (i*j==t) continue;
				if (d(d(i)*d(j))==d(t))
				{
					ans++;
//					if (i==n||j==n||t==n)
//						printf("%d	%d	%d\n",i,j,t);
				}
			}
		}
	}
	printf("%d	%d\n",n,ans);
	last=ans;
//	}
*/	/*for(int i=1;i<=sqrt((double)n);i++)
	{
		if (n%i==0)
			if (d(n)!=d(d(i)*d(n/i))) ans++;
	}*/
	return 0;
}


#include <stdio.h>

int n;
int a[20];
__int64 ans,s;

int main()
{
    scanf("%d",&n);
    ans=0;
    for(int i=1;i<=n;i++)
     a[i]=0;
    for(int i=1;i<=n;i++)
     a[i%9]++;
    for(int i=0;i<9;i++)
      for(int j=0;j<9;j++)
     ans+=a[i]*a[j]*a[i*j%9];
     s=0;
    for(int i=1;i<=n;i++)
      for(int j=i;j<=n;j+=i)
       s++;
    printf("%I64d\n",ans-s);
}


#include <bits/stdc++.h>
#define pi 3,141592653589793238462643
using namespace std;
int btd(int n){
	 int decimalNumber = 0, i = 0, remainder;
    while (n!=0)
    {
        remainder = n%10;
        n /= 10;
        decimalNumber += remainder*pow(2,i);
        ++i;
    }
    return  decimalNumber;
	}
string dtb(int n){
	string x="";

	while(n){
		if(n%2==1)
		x.push_back('1');
		else if(n%2==0)
		x.push_back('0');
		n/=2;
	}
	reverse(x.begin(),x.end());
	return x;
}
string tos(int n){
	string x;
	while(n){
	x+=(n%10);
	n/=10;
	}
return x;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    long long a,b;
    cin >> a >> b;
    int q =btd(a) ^ btd(b);
    string j = tos(a);
	string p = dtb(q), ans;
	int sz = j.size() - p.size();
	while(ans.length()<sz){
		ans+='0';
	}
	ans+=p;
	cout<<ans;
}
//Alik's


//
//  main.cpp
//  ultrafast mathematician
//
//  Created by Rishi Chhabra on 25/03/20.
//  Copyright © 2020 Rishi Chhabra. All rights reserved.
//

#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, const char * argv[]) {
//    char a[105],b[105],c[105];
    string a,b,c;
//    cout<<a.max_size();
    a.resize(100000000);
    b.resize(100000000);
    c.resize(100000000);
    cin>>a>>b;
    int l = a.length();
    for(int i=0;i<l;i++)
    {
        if(a[i]==b[i])
        {
            c[i] = '0';
        }
        else
        {
            c[i] = '1';
        }
    }
    for(int i=0;i<l;i++)
    {
        cout<<c[i];
    }
    return 0;
}


//
//  main.cpp
//  ultrafast mathematician
//
//  Created by Rishi Chhabra on 25/03/20.
//  Copyright © 2020 Rishi Chhabra. All rights reserved.
//

#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, const char * argv[]) {
//    char a[105],b[105],c[105];
    string a,b,c;
//    cout<<a.max_size();
    a.resize(256000000);
    b.resize(256000000);
    c.resize(256000000);
    cin>>a>>b;
    int l = a.length();
    for(int i=0;i<l;i++)
    {
        if(a[i]==b[i])
        {
            c[i] = '0';
        }
        else
        {
            c[i] = '1';
        }
    }
    for(int i=0;i<l;i++)
    {
        cout<<c[i];
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7
#define endl '\n'
#define pb push_back
#define r(i,n) for(ll i=0;i<n;i++)
typedef long long ll;

double tick(){
    static clock_t oldt,newt=clock();
    double diff=1.0* (newt-oldt)/CLOCKS_PER_SEC;
    oldt=newt;
    return diff;
}

string binary(ll x)
{
    string s;
    do
    {
        s.push_back('0' + (x & 1));
        // cout<<s<<endl;
    } while (x >>= 1);
    reverse(s.begin(), s.end());
    return s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ll t=1;
    // cin>>t;
    while(t--){
        string s1,s2;
        cin>>s1>>s2;
        ll a=bitset<64>(s1).to_ullong(),b=bitset<64>(s2).to_ullong();
        a=a^b;
        string bin=binary(a);
        string s(s1.size()-bin.size(),'0');
        bin=s+bin;
        cout<<bin<<endl;
    }
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
main(){
    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=n/2;i>1;i--)
        for(int j=0;j+2*i-1<n;j++)
            if(s.substr(j,i).compare(s.substr(j+i,i)) == 0){
                j+=i;
                c=i-1;
                while(j+2*i<n){
                    if(s.substr(j,i) == s.substr(j+i,i)){
                        j+=i;
                        c+=i-1;
                    }
                }
                i=1;
                break;
            }
    cout<<n-c;
}


#include <iostream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
#include <deque>
using namespace  std;
#define  ll long long
#define  ull unsigned long long
typedef pair<ll,ll>P;
static const ll INF=1e10;
static const ll len=2e3+5;
int main()
{
	ll n;
	while(cin>>n)
	{
		string  str;
		cin>>str;
		ll maxm=1;
		for(ll i=0;i<n;++i)
		{
			for(ll j=1;j<=(i+1)/2;++j)
			{
				string s1,s2;
				for(ll k=i;k>=i-j+1;k--)
				{
					s1+=str[k];
				}
				for(ll k=i-j;k>=i-j-j+1;k--)
				{
					s2+=str[k];
				}
				ll x=s1.size();
				if(s1==s2)maxm=max(x,maxm);
			}
		}
		cout<<n-maxm+1<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int m;
    string s;
    int num;
    while(scanf("%s",s)){
        scanf("%s",s);
        for(int i=1;i<=m;i++){
            if(s.substr(0,i)==s.substr(i,i)){num+i+1+m-i*2;}
        }
        printf("%d\n",num);
    }
}


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

int main()
{
	string x;
	int in;
	string tmp;
	string tmp1;
	cin>>in>>x;
	int on=in;
	char tmpa=x[0];
	bool u=false;
	on=on/2;
	while(u==false)
	{
		if(tmpa==x[on])
		{
			for(int b=0;b<on;b++)
			{
				tmp+=x[b];
				tmp1+=x[b+on];
			}
			if(tmp==tmp1)
			{
				u=true;
			}
		}
		else
		{
			on--;
		}
		if(on<0)
		{
			on=0;
			u=true;
		}
	}
	if(on>0)
	{
		in=in-on+1;
	}
	cout<<in;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

int f(int n) {
	if (n == 1) return -1;
	else if (n % 2 == 0) return f(n - 1) + n;
	else return f(n - 1) - n;
}

int main(){
	int n;
	cin >> n;
	cout << f(n);
	//system("pause");
	return 0;
}


#include <iostream>
#include"vector"
using namespace std;

int main()
{
	int n;
	cin >> n;
	long sum = 0;
	long number = 1;
	vector<int>mas;
	for (int i = 0; i<n; i++)
	{
		sum=n-(n-i-1);
		mas.push_back(sum);

	}

	for (int k = 0; k<n; k++)
	{
		if ((mas[k] % 2) != 0)
			mas[k] = -mas[k];
	}
	sum=-0;
	for (int i = 0; i<n; i++)
	{
		sum = sum + mas[i];
	}
	mas.clear();
	cout << sum;

}


#include <iostream>
#include"vector"
using namespace std;

int main()
{
	int n;
	cin >> n;
	long sum = 0;
	long number = 1;
	vector<int>mas;
	for (int i = 0; i<n; i++)
	{
		sum=n-(n-i-1);
		mas.push_back(sum);

	}

	for (int k = 0; k<n; k++)
	{
		if ((mas[k] % 2) != 0)
			mas[k] = -mas[k];
	}
	sum=-0;
	for (int i = 0; i<n; i++)
	{
		sum = sum + mas[i];
	}
     std::vector<int>().swap(mas);

	cout << sum;

}


//#include <cstdlib>
#include <iostream>
#include<math.h>
using namespace std;

int main()
{
    long long M=0,n;
    cin>>n;
    M=-1*pow((n+1)/2,2)+pow(n/2,2)+(n/2);
    cout<<M;

    //system("PAUSE");
    //return EXIT_SUCCESS;
}


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

int main()
{

	int n;
	char arr[n],c;
	//int brr[n] = {0};
	cin >>n;
	for(int i=0;i< n;i++)
	{
		cin >>c;
		arr[i] = tolower(c);
	}
	cout <<arr[0];

	for(int i=1;i<n;i++)
	{
		if(arr[i] =='a'||arr[i] =='o'||arr[i] =='e'||arr[i] =='i'||arr[i] =='u'||arr[i] =='y')
		{
			if(arr[i-1] =='a'||arr[i-1] =='o'||arr[i-1] =='e'||arr[i-1] =='i'||arr[i-1] =='u'||arr[i-1] =='y')
			{
				continue;
			}
			else
			{
				cout <<arr[i];
			}
		}
		else
		{
			cout <<arr[i];
		}
	}

	return 0;
}


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

int n;
int len;
char s[500];

bool isvowel(char c)
{
  return (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y');
}

void fixstr(char *s)
{
  n = strlen(s);
  int cnt = 0;
  int pos = -1;
  for (int i = 0; cnt != 2 && i < n; ++i) {
    if (isvowel(s[i])) {
      cnt = 1;
      for (int j = i+1; isvowel(s[j]) && j < n; ++j) {
        cnt++;
        pos=j;
      }
    }
  }

  if (cnt >= 2) {
    for (int i = 0; i < n-1; ++i) {
      if (i < pos) s[i] = s[i];
      else {
        s[i] = s[i+1];
      }
    }
    fixstr(s);
    len--;
  }
}

int main()
{
  ios::sync_with_stdio(false);
  #ifdef LOCAL_DEBUG
    freopen("in.txt","r",stdin);
  #endif

  cin >> n >> s;
  len = n;
  fixstr(s);
  for (int i = 0; i < len; ++i) {
    cout << s[i];
  }
  cout << endl;

  return 0;
}


#include <stdio.h>
#include <iostream>
#include <list>

using namespace std;
int main()
{
int n,i,w,first;
string s;
char c,c1;
cin >> n >> s;
while (((n>100) or (n<1)) or (s.length()!=n))
{

cin >> n >> s;

}

string ch="aeiouy";

for (i=1; i < s.length() ; i++)
{
	c=s[i];
	if (ch.find(c)!=-1)
		{
			c1=s[i-1];
			if (ch.find(c1)!=-1)
			{

				s.erase(i,1);
				i-=1;
			}
		}
}
cout << s;
return 0;
}


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

typedef long long ll;
typedef pair <ll, ll> pll;

const ll maxn = 7;
set <ll> g[maxn];
ll n, m;

void add_edge(ll a, ll b) {
    g[a].insert(b);
    g[b].insert(a);
}
void soak() {
    cin >> n >> m;
    for(ll i = 0; i < n; i++) g[i].clear();
    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        add_edge(a - 1, b - 1);
    }
}

ll condenc(ll a, ll b) {
    ll cnt = 0;
    for(auto i: g[a]) {
        if(g[b].count(i)) {
            cnt++;
        }
    }
    return cnt;
}
ll func() {
    ll answ = 0;
    for(ll i = 0; i < 7; i++) {
        for(ll j = i + 1; j < 7; j++) {
            ll temp = condenc(i, j);
            answ = max(answ, m - temp);
        }
    }
    return answ;
}

int main() {
    ios_base::sync_with_stdio(false);
    ll test = 5;
    while(test--) {
    soak();
    if(n < 7) cout << m;
    else cout << func();
    cout << endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int n, m, u, v;
    cin >> n >> m;
    int ans = 0;
    vi c(7);
    map<pair<int, int>, int> mp;
    for (int i = 0; i < m; i++){
        cin >> u >> v;
        if (u > v){
            swap(u, v);
        }
        if (u != 7 && v != 7 && !mp.count({u, v})){
            // Place that domino
            ans++;
            mp[{u, v}] = 1;
        }
        if (v == 7){
            // 7 is a wildcard node
            c[u] = 1;
        }
    }
    int d_c, d_mx = 0;
    for (int i = 1; i <= 6; i++){
        // Set wildcard to i
        d_c = 0;
        for (int j = 1; j <= 6; j++){
            if (mp.count({i, j}) || !c[u]){
                // Seen that domino, or not an edge
                continue;
            }
            int tmpi = i, tmpj = j;
            if (i > j){
                swap(tmpi, tmpj);
            }
            if (!mp.count({tmpi, tmpj})){
                d_c++;
            }
        }
        d_mx = max(d_mx, d_c);
    }
    cout << ans + d_mx << endl;
    return 0;
}


#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

vector<string>v;

void swap(char* s,int a,int b)
{
    char t=s[a];
    s[a]=s[b];
    s[b]=t;
}

void perm(string s,int l,int r)
{
    if(l==r)
        v.push_back(s);
    for(int i=l;i<=r;i++)
    {
        swap(&s[0],l,i);
        perm(s,l+1,r);
        swap(&s[0],l,i);
    }
}

int main()
{
    fast;
    int n,m;
    cin >> n >> m;
    string s="";
    for(int i=1;i<=n;i++)
        s+=to_string(i);
    perm(s,0,n-1);
    vector<pair<int,int> >v1;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin >> x >>y;
        v1.push_back(make_pair(x-1,y-1));
    }
    int M=0;
    for(int i=0;i<v.size();i++)
    {
        int a[n];
        for(int j=0;j<v[i].length();i++)
            a[j]=v[i][j]-48;
        map<pair<int,int>,int>m1;
        int temp=0;
        for(int j=0;j<v1.size();j++)
        {
            int x=a[v1[j].first],y=a[v1[j].second];
            if(m1.find(make_pair(x,y))==m1.end())
            {
                temp+=1;
                m1[make_pair(x,y)]=1;
                m1[make_pair(y,x)]=1;
            }
        }
        M=max(temp,M);
    }
    cout << M << endl;
}


/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAX3 2010
#define MAX4 20010
#define MAX5 200010
#define MAX6 2000010
#define MOD1 1000000007
#define MOD2 998244353

//cin.ignore (7777, '\n');

using namespace std;
using namespace __gnu_pbds;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}
  private:
    bool first;
    string separator;
};

template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll n,m;
vector<ll>adj[10];
ll used[10];
ll usedd[10];
ll cnt[10][10];
ll ans=0;

void dfs(ll v,ll c,ll prevv)
{
  used[v]=c;
  for(auto to:adj[v])
  {
	if(to==prevv)continue;
	if(used[to]==0)
	{
	  for(ll i=1;i<=6;i++)
	  {
		if(usedd[i]==0)
		{
		  ans++;
		  usedd[i]=1;
		  cnt[min(c,i)][max(c,i)]++;
		  dfs(to,i,v);
		  break;
	    }
	  }
	}
	else
	{
	  if(cnt[min(used[v],used[to])][max(used[v],used[to])]==0)
	  {
		cnt[min(used[v],used[to])][max(used[v],used[to])]=1;
		ans++;
	  }
    }
  }
}

int main(){
FAST_READ;
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
  ll x,y;
  cin>>x>>y;
  adj[x].pb(y);
  adj[y].pb(x);
}
ll maxx=0;
if(n<=6)cout<<m<<endl;
else
{
  for(ll i=1;i<=n;i++)
  {
	for(ll j=i+1;j<=m;j++)
	{
	  memset(used,0,sizeof(used));
	  memset(usedd,0,sizeof(usedd));
	  used[i]=1;
	  used[j]=1;
	  usedd[1]=1;
	  ans=0;
	  dfs(1,1,1);
	  maxx=max(maxx,ans);
    }
  }
  cout<<maxx<<endl;
}

return 0;
}


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

long long x, y, l, r;
vector<long long> all;

int main() {
  scanf("%lld %lld %lld %lld", &x, &y, &l, &r);
  long long xx = 1;
  bool okl = false;
  bool okr = false;
  for (int i = 0; i < 555; i++) {
    long long yy = 1;
    if (xx > r) break;
    for (int j = 0; j < 555; j++) {
      if (xx + yy == l) okl = true;
      if (xx + yy == r) okr = true;
      if (xx + yy > r) break;
      if (xx + yy >= l && xx + yy <= r) all.push_back(xx + yy);
      yy *= y;
    }
    if (xx > r) break;
    xx *= x;
  }
  sort(all.begin(), all.end());
  for (auto it : all) cerr << it << " ";
  cerr << endl;
  long long ans = 0;
  long long prv = l;
  for (int i = 0; i < (int) all.size(); i++) {
    ans = max(ans, all[i] - prv - okl);
    okl = true;
    prv = all[i];
  }
  ans = max(ans, r - prv - okr);
  if (all.empty()) {
    ans = max(ans, r - l + 1 - okl - okr);
  }
  printf("%lld\n", ans);
  return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long

using namespace std;

int main(){
    ll x,y,l,r;
    cin >> x >> y >> l >> r;

    ll p = 1;
    ll first[66],second[66];
    int n =0,m=0;
    while(p < r){
        first[n] = p;
        p *= x;
        n++;
    }
    p=1;
    while(p < r){
        second[m] = p;
        p*=y;
        m++;
    }

    ll merge[4356];
    int k = 0;
    for(int i=0;i < n; ++ i){
        for(int j=0;j < m;++j){
            if(first[i] + second[j] >= l && first[i] + second[j] <= r){
                merge[k] = first[i] + second[j];
                k++;
            }
        }
    }
    merge[k] = l-1;
    k++;
    merge[k] = r+1;
    k++;
    sort(merge,merge + k);

    ll ans =0 ;
    for(int i=0;i<k-1; ++i){
        ans = max(ans,merge[i+1] - merge[i]);
    }

    cout << ans - 1;
}


#include <bits/stdc++.h>

#define FILE_NAME ""

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

#define sc second
#define fr first

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1e12 + 1;
const int MOD = 1e9 + 7;

const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};

ll binpow(ll a, ll b) {
    ll res = 1ll;
    while (b) {
        if (b & 1ll) {
            b--;
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

int main() {
#ifdef LOCAL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll x, y, l, r;
    cin >> x >> y >> l >> r;
    ll last = 1;
    vector<ll> p;
    ll a = 0, b = 0;
    while (true) {
        ll next = last * x;
        if (next / x != last)
            break;
        a++;
        last = next;
        cerr << 1;
    }
    last = 1;
    while (true) {
        ll next = last * y;
        if (next / y != last)
            break;
        b++;
        last = next;
    }
    for (int i = 0; i <= a; i++) {
        ll fr = binpow(x, i);
        for (int j = 0; j <= b; j++) {
            ll sc = binpow(y, j);
            if (1e18 - fr < sc)
                continue;
            if (fr + sc >= l && fr + sc <= r)
                p.pb(fr + sc);
        }
    }
    sort(all(p));
    ll mx = 0;
    if (p.size() == 0)
        cout << r - l + 1, exit(0);
    for (int i = 0; i < p.size() - 1; i++)
        mx = max(mx, p[i + 1] - p[i] - 1);
    mx = max(mx, r - p[p.size() - 1]);
    mx = max(mx, p[0] - l);
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

#define FILE_NAME ""

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

#define sc second
#define fr first

#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1e12 + 1;
const int MOD = 1e9 + 7;

const int dx[] = {+1, -1, 0,  0};
const int dy[] = {0, 0, +1, -1};

ll binpow(ll a, ll b) {
    ll res = 1ll;
    while (b) {
        if (b & 1ll) {
            b--;
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

int main() {
#ifdef LOCAL
    freopen(FILE_NAME".in", "r", stdin);
    freopen(FILE_NAME".out", "w", stdout);
#endif
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll x, y, l, r;
    cin >> x >> y >> l >> r;
    ll last = 1;
    vector<ll> p;
    ll a = 0, b = 0;
    while (true) {
        ll next = last * x;
        if (next / x != last)
            break;
        a++;
        last = next;
        cerr << 1;
    }
    last = 1;
    while (true) {
        ll next = last * y;
        if (next / y != last)
            break;
        b++;
        last = next;
    }
    for (int i = 0; i <= a; i++) {
        ll fr = binpow(x, i);
        for (int j = 0; j <= b; j++) {
            ll sc = binpow(y, j);
            if (1e18 - fr < sc)
                continue;
            if (fr + sc >= l && fr + sc <= r)
                p.pb(fr + sc);
        }
    }
    sort(all(p));
    ll mx = 0;
    if (p.size() == 0)
        cout << r - l + 1, exit(0);
    for (int i = 0; i < p.size() - 1; i++)
        mx = max(mx, p[i + 1] - p[i] - 1);
    mx = max(mx, r - p[p.size() - 1]);
    mx = max(mx, p[0] - l);
    cout << mx;
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique((X).begin(),(X).end()),(X).end())
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define print(A,B) cout<<A<<" "<<B<<endl;
using namespace std;
void solve()
{
    ll n,x;
    cin>>n;
    while(n>=0)
    {
        x=n%10;
        n/=10;
        if(x==0)
            cout<<"O-|-OOOO"<<endl;
        if(x==1)
            cout<<"O-|O-OOO"<<endl;
        if(x==2)
            cout<<"O-|OO-OO"<<endl;
        if(x==3)
            cout<<"O-|OOO-O"<<endl;
        if(x==4)
            cout<<"O-|OOOO-"<<endl;
        if(x==5)
            cout<<"-O|-OOOO"<<endl;
        if(x==6)
            cout<<"-O|O-OOO"<<endl;
        if(x==7)
            cout<<"-O|OO-OO"<<endl;
        if(x==8)
            cout<<"-O|OOO-O"<<endl;
        if(x==9)
            cout<<"-O|OOOO-"<<endl;
    }
}
int main()
{
    fast;
    ll t;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
}


#include <stdio.h>
#include <conio.h>

using namespace std;

int main() {
	int c, l, i, x, mod, j, left, check = 0;
	char s[11];
	l = 0;
	left = 0;
	while((c = getchar()) != '\n' && c != '\0') {
		s[l++] = c - '0';
	}
	if (l > 0) {
		for (i = 0; i < l; i++) {
			if (s[i] == 0) {
				left++;
			} else {
				check = 1;
				break;
			}
		}
		if (check == 0) {
			left--;
		}
	}
	for (i = l - 1; i >= left; i--) {
		x = s[i];
		if (x < 5) {
			printf("O-|");
		} else {
			printf("-O|");
		}
		mod = x % 5;
		for (j = 0; j < mod; j++) {
			printf("O");
		}
		printf("-");
		for (j = 0; j < 4 - mod; j++) {
			printf("O");
		}
		putchar('\n');
	}
	getch();
	return 0;
}


/*
                                                           _     _
                                                          (c).-.(c)
                                                           / ._. \
                                                         __\( Y )/__
                                                        (_.-/'-'\-._)
                                                           ||   ||
                                                         _.' `-' '._
                                                        (.-./`-'\.-.)
                                                         `-'     `-'

                 ▄▀▀▄ ▄▀▀▄  ▄▀▀█▀▄   ▄▀▀▄ ▄▀▀▄     ▄▀▀▀▀▄  ▄▀▀▄ ▄▄   ▄▀▀▄ ▄▀▀▄  ▄▀▀█▄▄   ▄▀▀▄ ▄▄   ▄▀▀█▄   ▄▀▀▄ ▄▀▄
                █   █    █ █   █  █ █   █    █    █ █   ▐ █  █   ▄▀ █   █    █ ▐ ▄▀   █ █  █   ▄▀ ▐ ▄▀ ▀▄ █  █ ▀  █
                ▐  █    █  ▐   █  ▐ ▐  █    █        ▀▄   ▐  █▄▄▄█  ▐  █    █    █▄▄▄▀  ▐  █▄▄▄█    █▄▄▄█ ▐  █    █
                   █   ▄▀      █       █   ▄▀     ▀▄   █     █   █    █    █     █   █     █   █   ▄▀   █   █    █
                    ▀▄▀     ▄▀▀▀▀▀▄     ▀▄▀        █▀▀▀     ▄▀  ▄▀     ▀▄▄▄▄▀   ▄▀▄▄▄▀    ▄▀  ▄▀  █   ▄▀  ▄▀   ▄▀
                           █       █               ▐       █   █               █    ▐    █   █    ▐   ▐   █    █
                           ▐       ▐                       ▐   ▐               ▐         ▐   ▐            ▐    ▐

                                                     #                 #
                                                     #=ooO=========Ooo=#
                                                     #  \\  (o o)  //  #
                                                     --------(_)--------
*/

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long int n;
    cin>>n;
    vector<string>s;
    s.push_back("O-|-OOOO");
    s.push_back("O-|O-OOO");
    s.push_back("O-|OO-OO");
    s.push_back("O-|OOO-O");
    s.push_back("O-|OOOO-");
    s.push_back("-O|-OOOO");
    s.push_back("-O|O-OOO");
    s.push_back("-O|OO-OO");
    s.push_back("-O|OOO-O");
    s.push_back("-O|OOOO-");
    while(n>=0){
        int r = n%10;
        cout<<s[r]<<endl;
        n=n/10;
    }

    return 0;
 }

/*
              (`-') _           (`-')                  (`-').->(`-').->           <-.(`-') (`-').->(`-')  _ <-. (`-')
             _(OO )(_)         _(OO )                  ( OO)_  (OO )__      .->    __( OO) (OO )__ (OO ).-/    \(OO )_
        ,--.(_/,-.\,-(`-'),--.(_/,-.\                 (_)--\_),--. ,'-',--.(,--.  '-'---.\,--. ,'-'/ ,---.  ,--./  ,-.)
        \   \ / (_/| ( OO)\   \ / (_/                 /    _ /|  | |  ||  | |(`-')| .-. (/|  | |  || \ /`.\ |   `.'   |
         \   /   / |  |  ) \   /   /        (`-')     \_..`--.|  `-'  ||  | |(OO )| '-' `.)  `-'  |'-'|_.' ||  |'.'|  |
        _ \     /_||  |_/ _ \     /_)    <-.(OO )     .-._)   \  .-.  ||  | | |  \| /`'.  |  .-.  (|  .-.  ||  |   |  |
        \-'\   /   |  |'->\-'\   /       ,------.)    \       /  | |  |\  '-'(_ .'| '--'  /  | |  ||  | |  ||  |   |  |
            `-'    `--'       `-'        `------'      `-----'`--' `--' `-----'   `------'`--' `--'`--' `--'`--'   `--'
*/


#include<iostream>
using namespace std;
int biaoshi(int n)
{
    if(n==0)
      {
          cout<<"O-|-OOOO"<<endl;
      }
    else if(n==1)
    {
       cout<<"O-|O-OOO"<<endl;
    }
     else if(n==2)
    {
        cout<<"O-|OO-OO"<<endl;
    }
     else if(n==3)
    {
        cout<<"O-|OOO-O"<<endl;
    }
     else if(n==4)
    {
        cout<<"O-|OOOO-"<<endl;
    }
    else if(n==5)
    {
        cout<<"-O|-OOOO"<<endl;
    }
    else if(n==6)
    {
        cout<<"-O|O-OOO"<<endl;
    }
    else if(n==7)
    {
        cout<<"-O|OO-OO"<<endl;
    }
    else if(n==8)
    {
        cout<<"-O|OOO-O"<<endl;
    }
   // if(n==9)
    else
    {
        cout<<"-O|OOOO-"<<endl;
    }
    return 0;
}
int main()
{
    int n,a,b,c;
    cin>>n;
    a=n%10;
    b=(n/10)%10;
    c=n/100;
     biaoshi(a);
    if(c!=0)
    {
        biaoshi(b);
        biaoshi(c);
    }
    else
    {
        if(b!=0)
        {
            biaoshi(b);
        }
    }

       return 0;
}


#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 1000010;
const ll MOD = 1e9 + 7;

set<pair<int, int> > ss;

int ps[MAXN * 4];
ll sp[MAXN * 4];
ll rmq[MAXN * 4];
int n, m;
vector<pair<int, int> > op[MAXN];
vector<pair<int, int> > cl[MAXN];

void push(int v, int tl, int tr) {
	if (!ps[v])
		return;
	ps[v] = 0;
	ps[v * 2 + 1] = 1;
	ps[v * 2 + 2] = 1;
	sp[v * 2 + 1] = sp[v];
	sp[v * 2 + 2] = sp[v];
	int m = (tl + tr) >> 1;
	rmq[v * 2 + 1] = ((m - tl) * sp[v]) % MOD;
	rmq[v * 2 + 2] = ((tr - m) * sp[v]) % MOD;
}

void st(int v, int tl, int tr, int l, int r, ll x) {
	if (r <= tl || tr <= l)
		return;
	if (l <= tl && tr <= r) {
		ps[v] = 1;
		sp[v] = x;
		rmq[v] = (x * (tr - tl)) % MOD;
		return;
	}
	push(v, tl, tr);
	int m = (tl + tr) >> 1;
	st(v * 2 + 1, tl, m, l, r, x);
	st(v * 2 + 2, m, tr, l, r, x);
	rmq[v] = (rmq[v * 2 + 1] + rmq[v * 2 + 2]) % MOD;
}

ll get(int v, int tl, int tr, int l, int r) {
	if (r <= tl || tr <= l)
		return 0;
	if (l <= tl && tr <= r) {
		return rmq[v];
	}
	push(v, tl, tr);
	int m = (tl + tr) >> 1;
	return (get(v * 2 + 1, tl, m, l, r) + get(v * 2 + 2, m, tr, l, r)) % MOD;
}

int main() {
	int k;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < k; ++i) {
		int x1, x2, y1, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		--x1, --y1;
		op[x1].push_back(make_pair(y1, y2));
		cl[x2].push_back(make_pair(y1, y2));
	}
	st(0, 0, m, 0, 1, 1);
	for (auto j: op[0])
		ss.insert(j);
	for (int i = 1; i < n; ++i) {
		sort(op[i].begin(), op[i].end());
		reverse(op[i].begin(), op[i].end());
		for (auto j: op[i]) {
			auto it = ss.lower_bound(make_pair(j.second + 1, 0));
			int lb = 0;
			if (it != ss.begin()) {
				--it;
				lb = it->second;
			}
			ll cc = get(0, 0, m, lb, j.second + 1);
			st(0, 0, m, j.second, j.second + 1, cc);
		}
		for (auto j: cl[i])
			ss.erase(j);
		for (auto j: op[i]) {
			st(0, 0, m, j.first, j.second, 0);
			ss.insert(j);
		}
	}
	for (auto j: ss)
		st(0, 0, m, 0, j.second, 0);
	cout << get(0, 0, m, 0, m) << "\n";
	return 0;
}


%:pragma GCC optimize(2)
%:pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define pii pair <int, int>
#define sz(x) (int)x.size()

typedef long long ll;
const int N = 2000005;
const int mod = 1e9 + 7;

void Add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}

template <class T>
struct Bit_tree {
  #define lowbit(x) ((x) & (-x))
  T a[N];
  int n;
  void init(int _n) {
    fill_n(a + 1, n = _n, 0);
  }
  void add(int x, T d) {
    for (; x <= n; x += lowbit(x))
      Add(a[x], d);
  }
  T sum(int x) {
    T r = 0;
    for (; x >= 1; x ^= lowbit(x))
      Add(r, a[x]);
    return r;
  }
};
Bit_tree <int> f;

vector <pii> in[N], out[N];
set <pii> inv;
set <int> pts;

int n, m, k;

int main() {
  scanf("%d%d%d", &n, &m, &k);
  f.init(n);
  for (int i = 1; i <= k; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    in[y1].push_back(make_pair(x1, x2));
    out[y2 + 1].push_back(make_pair(x1, x2));
  }

  m++; in[m].push_back(make_pair(1, n - 1));
  pts.insert(1);
  inv.insert(make_pair(0, 0));

  f.add(1, 1);
  for (int i = 1; i <= m; i++) {
    if (sz(in[i]) || sz(out[i])) {
      //printf("I am zz! %d\n", i);
      sort(in[i].begin(), in[i].end());
      reverse(in[i].begin(), in[i].end());
      sort(out[i].begin(), out[i].end());
      //printf("I am AK! %d\n", i);
      for (auto e: in[i]) {
        auto it = inv.upper_bound(make_pair(e.second + 1, n));
        it--;
        //printf("qwq?");
        if (it->second <= e.second) {
          //printf("Oh, ");
          int s = (f.sum(e.second) - f.sum(it->second) + mod) % mod;
          //printf("I ");
          f.add(e.second + 1, i > 1 ? s : 0);
          //printf("AK ");
          pts.insert(e.second + 1);
          //printf("IOI");
        }
        //printf("\nqwq!\n");
      }
      //printf("I am fake! %d\n", i);
      for (auto e: in[i]) {
        auto it = pts.lower_bound(e.first);
        while (it != pts.end() && *it <= e.second) {
          int s = (f.sum(*it - 1) - f.sum(*it) + mod) % mod;
          f.add(*it, s);
          pts.erase(it++);
        }
      }
      //printf("I am faker! %d\n", i);
      for (auto e: out[i]) inv.erase(e);
      for (auto e: in[i]) inv.insert(e);
    }
  }

  printf("%d\n", f.sum(n));
  return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 4000005
#define P 1000000007
#define ll long long
using namespace std;
struct T
{
	ll x,l,r;
}c[N],d[N];
ll n,m,k,a[N],tg[N],b[N],Tg[N];
bool cmp(T x,T y)
{
	return x.x==y.x?x.l>y.l:x.x<y.x;
}
//-------------------------------------
void dn(ll k,ll l,ll r)
{
	ll mid=l+r>>1;
	if (tg[k])
	{
		a[k<<1]+=tg[k]*(mid-l+1);tg[k<<1]+=tg[k];
		a[k<<1|1]+=tg[k]*(r-mid);tg[k<<1|1]+=tg[k];
		tg[k]=0;
	}
}
void mdy(ll k,ll l,ll r,ll x,ll y,ll p)
{
	if (x<=l&&r<=y)
	{
		a[k]+=p*(r-l+1);tg[k]+=p;return;
	}
	ll mid=l+r>>1;dn(k,l,r);
	if (x<=mid) mdy(k<<1,l,mid,x,y,p);
	if (y>mid) mdy(k<<1|1,mid+1,r,x,y,p);
	a[k]=a[k<<1]+a[k<<1|1];
}
ll sum(ll k,ll l,ll r,ll x)
{
	if (r<=x) return a[k];
	ll mid=l+r>>1,ans;dn(k,l,r);
	ans=sum(k<<1,l,mid,x);
	if (x>mid) ans+=sum(k<<1|1,mid+1,r,x);
	return ans;
}
ll kth(ll k,ll l,ll r,ll x)
{
	if (l==r) return l;
	ll mid=l+r>>1;dn(k,l,r);
	if (a[k<<1]>=x) return kth(k<<1,l,mid,x);
	return kth(k<<1|1,mid+1,r,x-a[k<<1]);
}
//-------------------------------------
void down(ll k,ll l,ll r)
{
	if (Tg[k])
	{
		Tg[k<<1]=Tg[k<<1|1]=1;
		b[k<<1]=b[k<<1|1]=0;Tg[k]=0;
	}
}
void add(ll k,ll l,ll r,ll x,ll y)
{
	b[k]=(b[k]+y)%P;
	if (l==r)return;
	ll mid=l+r>>1;down(k,l,r);
	if (x<=mid) add(k<<1,l,mid,x,y);
	else add(k<<1|1,mid+1,r,x,y);
}
void gg(ll k,ll l,ll r,ll x,ll y)
{
	if (x<=l&&r<=y){b[k]=0;Tg[k]=1;return;}
	ll mid=l+r>>1;down(k,l,r);
	if (x<=mid) gg(k<<1,l,mid,x,y);
	if (y>mid) gg(k<<1|1,mid+1,r,x,y);
	b[k]=(b[k<<1]+b[k<<1|1])%P;
}
ll qry(ll k,ll l,ll r,ll x,ll y)
{
	if (x>y) return 0;
	if (x<=l&&r<=y) return b[k];
	ll mid=l+r>>1,Ans=0;down(k,l,r);
	if (x<=mid) Ans+=qry(k<<1,l,mid,x,y);
	if (y>mid) Ans+=qry(k<<1|1,mid+1,r,x,y);
	return Ans%P;
}
//-------------------------------------
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	for (ll i=1;i<=k;i++)
	{
		ll x1,y1,x2,y2;
		scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
		c[i]=(T){x1,y1,y2};
		d[i]=(T){x2,y1,y2};
	}
	sort(c+1,c+k+1,cmp);
	sort(d+1,d+k+1,cmp);

	ll now=1,pre=1,rnow=1;
	for (ll i=1;i<=n;i++)
	{
		if (i==2) add(1,1,m,1,1);
		while (now<=k&&c[now].x==i)
		{
			ll t=kth(1,0,m,sum(1,0,m,c[now].r+1))+1;
			//cout<<t<<c[now].r+1<<endl;
			t=qry(1,1,m,t,c[now].r+1);
			//cout<<t<<endl;
			gg(1,1,m,c[now].l,c[now].r+1);
			if (c[now].r<m) add(1,1,m,c[now].r+1,t);
			now++;
		}

		while (rnow<=k&&d[rnow].x==i-1)
		{
			//cout<<d[rnow].l<<' '<<d[rnow].r<<endl;
			mdy(1,0,m,d[rnow].l,d[rnow].r,-1);rnow++;
		}
		while (pre<now)
		{
			mdy(1,0,m,c[pre].l,c[pre].r,1);
			gg(1,1,m,c[pre].l,c[pre].r);

			pre++;
		}
	}
	ll t=kth(1,0,m,sum(1,0,m,m))+1;
	//cout<<sum(1,0,m,m)<<endl;
	printf("%lld\n",qry(1,1,m,t,m));
	//while(1);
}


/*
 * A.cpp
 *
 *  Created on: 29.10.2011
 *      Author: Altus
 */

#include<stdio.h>

const int ARRAY_LEN = 60000000;
int d[ARRAY_LEN];

int main()
{
	int cm, in, ft, tmp;

	scanf("%d", &cm);

	in = (cm + 1) / 3;
	ft = in / 12;
	in = in % 12;

	for(int i = 0, j = 1021; i < 500000000; i++, j++)
	{

//		if(j >= ARRAY_LEN) j -= ARRAY_LEN;
		j = j - j / ARRAY_LEN * ARRAY_LEN;
		tmp = i - i / ARRAY_LEN * ARRAY_LEN;
		d[j] = d[tmp];
//		d[tmp] = d[i % ARRAY_LEN];
	}

	d[0] = ft;
	printf("%d %d\n", d[0], in);
	return 0;
}


/*
 * A.cpp
 *
 *  Created on: 29.10.2011
 *      Author: Altus
 */

#include<stdio.h>

const int ARRAY_LEN = 60000000;
int d[ARRAY_LEN];

int main()
{
	int cm, in, ft, tmp;

	scanf("%d", &cm);

	in = (cm + 1) / 3;
	ft = in / 12;
	in = in % 12;

	for(int i = 0, j = 1021; i < 400000000; i++, j++)
	{

//		if(j >= ARRAY_LEN) j -= ARRAY_LEN;
		j = j - j / ARRAY_LEN * ARRAY_LEN;
		tmp = i - i / ARRAY_LEN * ARRAY_LEN;
		d[j] = d[tmp];
//		d[tmp] = d[i % ARRAY_LEN];
	}

	d[0] = ft;
	printf("%d %d\n", d[0], in);
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <stdlib.h>
using namespace std;

int main()
{
 int n;
 cin>>n;
 int a, b;
 n++;
 a=n/36;
 n=n-n/36*36;
 b=n/3;
 n=n-n/3*3;
 if (n>1) b++;
 cout<<a<<" "<<b;

  system("PAUSE");

}


// @author theyaserfox (edited version of peter50216's template)
// #includes {{{
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<functional>
#include<math.h>
#include<assert.h>
#include<stdarg.h>
#include<time.h>
#include<limits.h>
#include<ctype.h>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<vector>
#include<iostream>
#include<sstream>
using namespace std;
// }}}
// #defines {{{
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define REPL(i,x) for(int i=0;x[i];i++)
#define PER(i,n) for(int i=(n)-1;i>=0;i--)
#define PER1(i,a,b) for(int i=(a);i>=(b);i--)
#define RI(x) scanf("%d",&x)
#define DRI(x) int x;RI(x)
#define RII(x,y) scanf("%d%d",&x,&y)
#define DRII(x,y) int x,y;RII(x,y)
#define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define DRIII(x,y,z) int x,y,z;RIII(x,y,z)
#define RS(x) scanf("%s",x)
#define DRS(x) string x; RS(x) // added by aliabdallah
#define PI(x) printf("%d\n",x)
#define PIS(x) printf("%d ",x)
#define P(x) cout<<#x<<" = { "<<x<<" }\n"
#define CASET int ___T,cas=1;scanf("%d ",&___T);while(___T--)
#define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
#define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
#define MP make_pair
#define PB push_back
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define MSN(x,d) memset(x, d, sizeof(x))
#define SEP(x) ((x)?'\n':' ')
#define F first
#define S second
#define NTS(x,y) stringstream ss; ss << x; y = ss.str() //add by theyaserfox, note : '{' & '}' must be add before and after
#define STN(x,y) stringstream ss(x); ss >> y //add by theyaserfox, note : '{' & '}' must be add before and after
#ifdef ONLINE_JUDGE
#define FILEIO(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define FILEIOS freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define FILEIO(x) ;int main() {
#define FILEIOS ;
#endif
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VD> VVD;
typedef vector<string> VS;
const LL OO = 1e8;
const double EPS = (1e-7);
// }}}

// added and tested by theyaserfox {{{
VVI readAdjList() {
    DRII(n, e);
    VVI adjList(n+1);
    REP(i,e) {
        DRII(u, v);
        adjList[u].PB(v);
        adjList[v].PB(u);
    }
    return adjList;
}

void DFS(int node, VVI & adjList, VI & visited) {
    visited[node] = true;
    REPL(i, adjList[node]) {
        int child = adjList[node][i];
        if (!visited[child]) //To avoid cyclic behavior
            DFS(child, adjList, visited);
    }
}

VI BFS(int s, VVI & adjList) {
    VI len(SZ(adjList),OO);
    queue<PII> q;
    q.push(MP(s,0)); len[s] = 0;
    int cur, dep;
    while(!q.empty()) {
        PII p = q.front(); q.pop();
        cur = p.F; dep = p.S;
        REPL(i, adjList[cur]){
            int child = adjList[cur][i];
            if(len[child] == OO) {
                q.push(MP(child,dep+1)); len[child] = dep+1;
            }
        }
    }
    return len;
}
// }}}

int GCD(int a, int b)
{
    if(b == 0)
        return a;
    else
        return GCD(b, a%b);
}

int main()
{
     int feet;
     DRI(n);
    int inch = n/3;
    feet=inch/12;

    if(n%3==2){ inch++;}
    int temp=inch/12;
    temp*=12;
    inch-=temp;

    cout<<feet<<" "<<inch<<endl;

    system("pause");
    return 0;
}

// vim: fdm=marker:commentstring=\ \"\ %s:nowrap:autoread


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;

	for(int i=0;i<s.length()-1;i++)
	{
		if(count(s.begin(),s.end(),s[i])>=2)
		{
			for(int j=0;j<s.length();j++)
				if(s[j]==s[i])s[j]=s[i+1];
		}
	}

	cout<<( count(s.begin(),s.end(),s[0])==s.length() ? "YES" : "NO" );
}
//CodeNumber : 219


#include<bits/stdc++.h>

using namespace std;
const int maxn = 1e5+10;

char ch[maxn],b[30];

int main(){
    int T,sum,sum2;
    while(~scanf("%d",&T)){
        memset(b,0,sizeof(b));
        if(T == 1)
            printf("Yes\n");
        else{
        scanf("%s",ch);
        for(int i = 0;i<T;i++){
            b[ch[i] - 'a']++;
        }
        sum = 0,sum2 = 0;
        for(int i = 0;i<26;i++){
            if(b[i] == 1)
                sum++;
            if(b[i]>1)
                sum2++;
        }
        if(sum2>=1 )
            printf("Yes\n");
        else
            printf("No\n");
        }

    }
    return 0;

}


#include <iostream>

using namespace std;
int frq[1000000];
int main()
{
int n;
char s[30];
cin>>n;
for(int i=0;i<n;i++){
    cin>>s[i];
    frq[s[i]]++;
}

for(int i=0;i<n;i++){
if(frq[s[i]]>=2||n==1)
    {cout<<"Yes";
    break;}
else{
    cout<<"No";
    break;
}}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int adj[9999][9999];
int main()
{
	int i, j, k;
	int n, m;
	string s;

	int mp[26];
	memset(mp, 0, sizeof(mp));

	cout<<(n);
	cin >> s;

	if (n == 1) {
		cout<<"Yes\n";
		return 0;
	}

	for (i = 0; i < n; i++)
		mp[s[i] - 'a']++;

	bool f1=0 , f2 = 0;
	for (i = 0; i < 26; i++)
	{
		if (mp[i] == 1)
			f1 = 1;

		else if (mp[i] > 1)
			f2 = 1;
	}

	if (f1) {
		if (f2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}

	else
		cout<<"Yes\n";

	return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public
#define TynKogep TOPCODER
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define sz size()
#define ld long double
#define ll long long
#define mp make_pair
#define istr istringstream

const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-9;

int a[50000],na[50000];

int main()
{
//    freopen("q.in", "rt", stdin);
//    freopen("q.out", "wt", stdout);
    cout.flags(ios::fixed);
    ll x;
    cout.precision(2);
    cin>>x;
    if (x==0) {cout<<0; return 0;}
    if (x>10000)
    {
        if (x<0) x=-x;
        ll now=0,st=1,ans=0;
        while(now<x)
        {
            now+=st;
            st++;
            ans++;
        }

        if ((now-x)%2==0) cout<<ans; else cout<<ans+1;
        return 0;
    }
    clr(a);
    a[20000]=1;
    for(int i=1;i<10000;i++)
    {
        clr(na);
        for(int j=0;j<=40000;j++)
        {
            if (a[j]==i && j-i>=0 && a[j-i]<=i) {na[j-i]=i+1;}
            if (a[j]==i && j+i<=40000 && a[j+i]<=i) {na[j+i]=i+1;}
        }
        for(int j=0;j<=40000;j++)
        a[j]=na[j];
        if (a[20000+x])
        {
            cout<<a[20000+x]-1;
            return 0;
        }
    }
    return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public
#define TynKogep TOPCODER
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define sz size()
#define ld long double
#define ll long long
#define mp make_pair
#define istr istringstream

const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-9;

int a[50000],na[50000];

int main()
{
//    freopen("q.in", "rt", stdin);
//    freopen("q.out", "wt", stdout);
    cout.flags(ios::fixed);
    int x;
    cout.precision(2);
    cin>>x;
    if (x==0) {cout<<0; return 0;}
    if (x>10000)
    {
        if (x<0) x=-x;
        int now=0,st=1,ans=0;
        while(now<x)
        {
            now+=st;
            st++;
            ans++;
        }

        if ((now-x)%2==0) cout<<ans; else cout<<ans+1;
        return 0;
    }
    clr(a);
    a[20000]=1;
    for(int i=1;i<10000;i++)
    {
        clr(na);
        for(int j=0;j<=40000;j++)
        {
            if (a[j]==i && j-i>=0 && a[j-i]<=i) {na[j-i]=i+1;}
            if (a[j]==i && j+i<=40000 && a[j+i]<=i) {na[j+i]=i+1;}
        }
        for(int j=0;j<=40000;j++)
        a[j]=na[j];
        if (a[20000+x])
        {
            cout<<a[20000+x]-1;
            return 0;
        }
    }
    return 0;
}


#include <iostream>
#define MAX 1000000
using namespace std;
struct node
{
	int pos;
	int num;
};
node queue[100005];
int main ()
{
	int x;
	int head,p,temp;
	while(scanf("%d",&x)!=EOF)
	{
		if(x==0){printf("0\n");continue;}
		head=0;
		p=0;
		queue[p].pos=0;
		queue[p++].num=0;
		while(p!=head)
		{
			temp=head;
			if(queue[temp].pos==x)break;
			head++;
			if(head==MAX)head=0;
			queue[p].pos=queue[temp].pos+queue[temp].num+1;
			queue[p++].num=queue[temp].num+1;
			if(p==MAX)p=0;
			queue[p].pos=queue[temp].pos-queue[temp].num+1;
			queue[p++].num=queue[temp].num+1;
			if(p==MAX)p=0;

		}
		printf("%d\n",queue[temp].num);
	}
}


#include<iostream>
#include<conio.h>

int n,i,s;

int main()
{
    std :: cin >> n;
    for(n=n<0?-n:n; s<n||s%2!=n%2; s+=i)i++;
    std :: cout << i;

    getch();
}


#include <stdio.h>
#include <vector>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;

int val(char x)
{
    if (x>='0'&&x<='9')
       return x-'0';
    return x-'A'+10;
}

int main ()
{
    char x[20];
    string str;
    int i,j,k,l;
    string n1,n2;
    scanf ("%s",x);
    str=x;
    vector <int> ret;
    for (i=0;i<str.size();i++)
    {
        if (str[i]==':')
        {
            i++;
            break;
        }
        n1+=str[i];
    }
    for (i;i<str.size();i++)
        n2+=str[i];
    while (n1[0]=='0')
        n1=n1.substr(1,n1.size());
    while (n2[0]=='0')
        n2=n2.substr(1,n2.size());
    if (n1.size()==1&&n2.size()==1)
    {
        printf ("-1\n");
        return 0;
    }
    for (i=2;;i++)
    {
        int s1=0,s2=0,fact=1;
        bool f=1;
        for (j=n1.size()-1;j>=0;j--)
        {
            if (val(n1[j])>=i)
            {
                f=0;
                break;
            }
            s1+=val(n1[j])*fact;
            fact*=i;
        }
        fact=1;
        for (j=n2.size()-1;j>=0;j--)
        {
            if (val(n2[j])>=i)
            {
                f=0;
                break;
            }
            s2+=val(n2[j])*fact;
            fact*=i;
        }
        if (!f)
           continue;
        if (s1<24&&s2<60)
           ret.push_back(i);
        else
           break;
    }
    for (i=0;i<ret.size();i++)
        printf ("%d\n",ret[i]);
    if (ret.size()==0)
       printf ("0\n");
    scanf (" ");
     return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

char S[15];
int Sep, N, MaxD;
vector<int> Ans;

int Digit(int Pos)
{
    return ('0' <= S[Pos] && S[Pos] <= '9' ? S[Pos] - '0' : S[Pos] - 'A' + 10);
}

int Nr(int Left, int Right, int Base)
{
    int Ans = 0;
    for(int i = Left; i <= Right; ++ i)
        Ans = Ans * Base + Digit(i);
    return Ans;
}

int main()
{
    gets(S + 1);
    N = strlen(S + 1);

    for(int i = 1; i <= N; ++ i)
        if(S[i] == ':')
            Sep = i;

    int CntLeft = 0, CntRight = 0;
    for(int i = 1; i < Sep; ++ i) CntLeft += S[i] != '0';
    for(int i = Sep + 1; i <= N; ++ i) CntRight += S[i] != '0';

    if(CntLeft == 1 && S[Sep - 1] != '0' && Digit(Sep - 1) < 24 && CntRight == 1 && S[N] != '0' && Digit(N) < 60)
    {
        printf("-1");
        return 0;
    }
    if(CntLeft == 0 && CntRight == 0)
    {
        printf("-1");
        return 0;
    }

    for(int i = 1; i <= N; ++ i)
        if(i != Sep)
            MaxD = max(MaxD, Digit(i));

    for(int i = MaxD + 1; Nr(1, Sep - 1, i) < 24 && Nr(Sep + 1, N, i) < 60; ++ i)
        Ans.push_back(i);

    if(Ans.size() == 0) printf("0");
    else
    {
        for(int i = 0; i < Ans.size(); ++ i)
            printf("%i ", Ans[i]);
    }
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
char str[100010],h[100010],m[100010];
ll int mh,mm,lh,lm;
ll int priority(char c)
{
	if(c>='0' && c<='9')
	return c-'0';
	return ((c-'A') +10);
}
void find_time(ll int r)
{
	ll int i,p=1;
	for(i=(lh-1);i>=0;i--)
	{
		mh+=p*priority(h[i]);
		p*=r;
		//~ cout<<mh<<endl;
	}
	p=1;
	for(i=(lm-1);i>=0;i--)
	{
		mm+=p*priority(m[i]);
		p*=r;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%s",str);
	ll int i,j,mymax;
	//~ int x,y;
	//~ sscanf(str,"%d:%d",&x,&y);
	//~ cout<<x<<endl<<y<<" "<<endl;
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]==':')
		{
			h[i]='\0';
			break;
		}
		h[i]=str[i];
	}
	j=0;i++;
	for(;;i++)
	{
		if(str[i]=='\0')
		{
			m[j]='\0';
			break;
		}
		else
		m[j++]=str[i];
	}

	lh=strlen(h);lm=strlen(m);
	bool um,uh,all=1;
	for(i=(lh-1);i>=0;i--)
	{
		if(i<(lh-1) && h[i]!='0')
		uh=1;
		if(h[i]!='0')
		all=0;
	}
	for(i=(lm-1);i>=0;i--)
	{
		if(i<(lm-1) && m[i]!='0')
		um=1;
		if(m[i]!='0')
		all=0;
	}
	if(all)
	{
		cout<<-1<<endl;
	}
	else if(uh==0 && um==0)
	{
		mh=0;mm=0;
		find_time(1);
		if(mh<=23 & mm<=60)
		{
			cout<<-1<<endl;
		}
		else if(mh==24 && mm==0)
		{
			cout<<-1<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
	else
	{
		mymax=0;//as we know all are not zero
		vector<ll int> r;
		for(i=0;i<lh;i++)
		{
			mymax=max(mymax,priority(h[i]));
		}
		for(i=0;i<lm;i++)
		{
			mymax=max(mymax,priority(m[i]));
		}
		//~ cout<<mymax<<endl;
		for(i=mymax+1;;i++)
		{
			mh=0;mm=0;
			find_time(i);
			//~ cout<<mh<<" "<<" "<<mm<<endl;
			if(mh<=23 && mm<=60)
			r.push_back(i);
			else if(mh==24 && mm==0)
			r.push_back(i);
			else
			break;
		}
		if(r.size()!=0)
		{
			for(i=0;i<r.size();i++)
			cout<<r[i]<<" ";
			cout<<endl;
		}
		else
		cout<<0<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
char str[100010],h[100010],m[100010];
ll int mh,mm,lh,lm;
ll int priority(char c)
{
	if(c>='0' && c<='9')
	return c-'0';
	return ((c-'A') +10);
}
void find_time(ll int r)
{
	ll int i,p=1;
	for(i=(lh-1);i>=0;i--)
	{
		mh+=p*priority(h[i]);
		p*=r;
		//~ cout<<mh<<endl;
	}
	p=1;
	for(i=(lm-1);i>=0;i--)
	{
		mm+=p*priority(m[i]);
		p*=r;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	scanf("%s",str);
	ll int i,j,mymax;
	//~ int x,y;
	//~ sscanf(str,"%d:%d",&x,&y);
	//~ cout<<x<<endl<<y<<" "<<endl;
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]==':')
		{
			h[i]='\0';
			break;
		}
		h[i]=str[i];
	}
	j=0;i++;
	for(;;i++)
	{
		if(str[i]=='\0')
		{
			m[j]='\0';
			break;
		}
		else
		m[j++]=str[i];
	}

	lh=strlen(h);lm=strlen(m);
	bool um,uh,all=1;
	for(i=(lh-1);i>=0;i--)
	{
		if(i<(lh-1) && h[i]!='0')
		uh=1;
		if(h[i]!='0')
		all=0;
	}
	for(i=(lm-1);i>=0;i--)
	{
		if(i<(lm-1) && m[i]!='0')
		um=1;
		if(m[i]!='0')
		all=0;
	}
	if(all)
	{
		cout<<-1<<endl;
	}
	else if(uh==0 && um==0)
	{
		cout<<"here "<<endl;
		mh=0;mm=0;
		find_time(1);
		if(mh<=23 & mm<=60)
		{
			cout<<-1<<endl;
		}
		else if(mh==24 && mm==0)
		{
			cout<<-1<<endl;
		}
		else
		{
			cout<<0<<endl;
		}
	}
	else
	{
		mymax=0;//as we know all are not zero
		vector<ll int> r;
		for(i=0;i<lh;i++)
		{
			mymax=max(mymax,priority(h[i]));
		}
		for(i=0;i<lm;i++)
		{
			mymax=max(mymax,priority(m[i]));
		}
		//~ cout<<mymax<<endl;
		for(i=mymax+1;;i++)
		{
			mh=0;mm=0;
			find_time(i);
			//~ cout<<mh<<" "<<" "<<mm<<endl;
			if(mh<=23 && mm<=60)
			r.push_back(i);
			else if(mh==24 && mm==0)
			r.push_back(i);
			else
			break;
		}
		if(r.size()!=0)
		{
			for(i=0;i<r.size();i++)
			cout<<r[i]<<" ";
			cout<<endl;
		}
		else
		cout<<0<<endl;
	}
	return 0;
}


#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main()
{
	string s,adress;
	int k,j;
	char a;
	cin>>s;
	if (s[0]=='h' && (s[1]=='t') && (s[2]=='t') && (s[3]=='p'))
	{
		k=4;
	adress.append("http://");
	}
	if (s[0]=='f' && (s[1]=='t') && (s[2]=='p')) 	{
		k=3;
		adress.append("ftp://");
		}

	for (int i=k;i<s.length();i++)
	{
        j=i;
		a=s[i];
		if ((a=='r') and (s[i+1]=='u')) break; else adress.push_back(a);;
	}

		adress.append(".ru/");

	    for (int i=j+2;i<s.length();i++)
	{
		a=s[i];
    adress.push_back(a);
    }
	cout<<adress;
getch();
}


// created by Marchecnko Vadim
// I did it for my fun =)
// v 0.1

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <conio.h>

using namespace std;

int a[200];
int main(){
	string ss;
	getline(cin,ss);
	int f1;
	if (ss.find("http")==0) f1=4;
	else f1=3;
	int i;
	for (i=0; i<f1 ; ++i) cout<<ss[i];
	cout << "://";
	cout<<ss[i++]<<".";
	cout<<ss[i++];
	if (i!=ss.length()) cout<<"/";
	for (int j=i; j<ss.length(); ++j) cout<<ss[j];
	_getch();
	return 0;
}


#include<iostream>
int dp[102][102];
int dp2[102][102];
int a[1000];

bool checkeven(int start, int end);
bool check(int start, int end);

int main() {
	for (int i = 0; i < 102; i++) {
		for (int j = 0; j < 102; j++) {
			dp[i][j] = -1;
			dp2[i][j] = -1;
		}
	}
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++)std::cin >> a[i];

	if (check(0, n - 1))std::cout << "Yes\n";
	else std::cout << "No\n";
	system("pause");
	return 0;
}

bool check(int start, int end) {

	if (start >= end)return dp[start][end]=false;
	if (dp[start][end] != -1)return dp[start][end];

	if ((end - start) % 2 == 1)return dp[start][end] = false;
	if ((end - start) % 2 == 0) {
		if (a[start] % 2 == 1 && a[end] % 2 == 1)return dp[start][end] = true;
		else return dp[start][end] = false;
	}
}


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

int main() {
	int a,i;
 int arr[a];
 cin>>a;
 for(i=0;i<a;i++){
 	cin>>arr[i];
 }
 if(arr[0]%2==0||arr[a-1]%2==0||a%2==0){
 	cout<<"No";

 }
 else{
   cout<<"Yes";
 }
	return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef vector<int> vi;

int n;
int arr[109];

bool solve() {
  // First populate with intersections
  vi inter;
  for (int i = 0; i < n - 1; ++i) {
    if (arr[i] % 2 != 0 && arr[i+1] % 2 != 0)
      inter.push_back(i);
  }
  for (int i = 0; i < inter.size() - 1; ++i) {
    if (inter[i] % 2 == 0) {
      // We can take this one since it is at an even index.
      for (int j = i + 1; j < inter.size(); ++j) {
        if ((inter[j] - inter[i]) % 2 != 0 && (n - (inter[j] + 1)) % 2 != 0) {
          //cout << inter[i] << " " << inter[j] << endl;
          return true;
        }
      }
    }
  }
  return false;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }

  if (arr[0] % 2 != 0 && arr[n-1] % 2 != 0 && solve()) {
    cout << "Yes" << endl;
  } else cout << "No" << endl;
};


/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;

const int N = 1e5;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int tc, ca = 0;
  int n, el;
  cin >> n;
  vector <int> v;
  for (int i = 0;i < n;i++){
    cin >> el;
    if (el%2)v.pb(i);
  }
  string ans = "No";
  //cout << v[v.size()-1] - v[0] << '\n';
  if ((v[v.size()-1]-v[0]) % 2 == 0)ans = "Yes";
  cout << ans << '\n';
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M_PIl   3.141592653589793238462643383279502884L
set<ll> ans;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;

    vector<int> a = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292};
    if (n < a.size()) return a[n];
    else return a[11] + 49 * (n - 11);

    return 0;
}


#include <iostream>
#include<cstdio>
using namespace std;
long long fun(long n)
{
 int i,j,k,a[10000000]={0};
 long long sum=0;
 for(i=0;i<=n;i++)
  for(j=0;i+j<=n;j++)
   for(k=0;i+j+k<=n;k++)
   {
    long long t=i+j*5+k*10+(n-i-j-k)*50;
    if(!a[t])
    {
     a[t]=1;
     sum++;
    }
   }
 return sum;
}
int main() {
 long x;
 scanf("%lld",&x);
 long long ans;
 if(x<=11)
    ans=fun(x);
 else
    ans=fun(11)+(x-11)*49;
 cout<<ans;
}


	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define ll long long
	#define ld long double
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second

	using namespace std;

	int flag[1000001];
	int answ;
	ll func(ll n)
	{
		if(n<9)
			return 1+n+n*(n+1)/2;
		return 1+n+n*(n+1)/2-(n-8)*(n-8+1)/2;
	}

	int main()
	{
		std::ios::sync_with_stdio(false);
		int T;
		T=1;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			ll ans=0;
			ll n;
			cin>>n;
			if(n<=5)
			{
				ans=1+n+n*(n+1)/2+n*(n+1)*(n+2)/6;
			}
			else
			{
				ans=func(n)+func(n-1)+func(n-2)+func(n-3)+func(n-4)+func(n-5);
				if(n>=9)
					ans=ans-(n-8)*(n-8+1)/2;
				if(n>14)
					ans=ans+(n-13)*(n-13+1)/2;
			}
			cout<<ans<<endl;
		}
		return 0;
	}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <memory.h>
#include <limits>
#include <string>
#include <sstream>
#include <queue>
#include <list>
#include <stack>
#include <iterator>

using namespace std;
int gcd(int a, int b) {
    if (a == b) return a;
    if (a > b)  return gcd(a-b, b);
    if (a < b)  return gcd(a, b - a);
}

int main() {
    int a,b,c,d;
    scanf("%d%d%d%d", &a,&b,&c,&d);

    int t1, t2;
    //if (a >= c && b >= d) {
        if (c > d) {
            int ba = a;
            a *= c;
            b *= c;
            c *= ba;
            d *= ba;
        } else if (d > c) {
            int bb = b;
            b *= d;
            a *= d;
            c *= bb;
            d*= bb;
        } else {
            int bc = min(a, b);
            b *= d;
            a *= d;
            c *= bc;
            d*= bc;
        }
//  }

    /*a*=t2;b*=t2;
    c*=t1;d*=t1;*/

    int aa = abs(a - c);
    int bb = abs(b-d);

    int cc; int p;
    if (aa > 0) {
        cc = aa;
        p = a;
    } else {
        cc = bb;
        p = b;
    }

    int dd = gcd(cc, p);
    cc /= dd;
    p  /= dd;

    printf("%d/%d\n", cc, p);
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b)
{
    if(a==b)
        return a;
    if(a==1||b==1)
        return 1;
    if(a>b)
        return gcd(a-b,b);
    else
        return gcd(a,b-a);
}

int main(int argc, char const *argv[])
{
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    //c=c*a*b;
    //d=d*a*b;
    if(c*b>d*a)
    {
        long long int gcd_req=gcd(c*b-a*d,c*b);
        cout<<(c*b-a*d)/gcd_req<<"/"<<(c*b)/gcd_req;
    }
    else
    {
        long long int gcd_req=gcd(d*a-b*c,d*a);
        cout<<(a*d-c*b)/gcd_req<<"/"<<(d*a)/gcd_req;
    }
    return 0;

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

int gcd(int a, int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}

int main()
{
    int a, b, c, d;
    while(cin >> a >> b >> c >> d)
    {
        if(a>b) swap(a,b);
        if(c>d) swap(c,d);
        c*=b, d*=b;
        if(c/a==d/b&&c%a==0&&d%b==0) puts("0/1");
        else
        {
            double minn;
            int s, m, p, q, g;
            if(1.0*(d-b)/d<=1.0*(c-a)/c)
            {
                p=b*c-a*d; q=b*c;
                g=gcd(q,p);
                minn=1.0*p/q;
                s=p/g, m=q/g;
            }
            else
            {
                p=a*d-b*c; q=a*d;
                g=gcd(q,p);
                minn=1.0*p/q;
                s=p/g, m=q/g;
            }
            swap(a,b);
            if(1.0*(d-b)/d<=1.0*(c-a)/c)
            {
                p=b*c-a*d; q=b*c;
                g=gcd(q,p);
                if(1.0*p/q<minn)
                    s=p/g, m=q/g;
            }
            else
            {
                p=a*d-b*c; q=a*d;
                g=gcd(q,p);
                if(1.0*p/q<minn)
                    s=p/g, m=q/g;
            }
            printf("%d/%d\n",s,m);
        }
    }
    return 0;
}


#include <stdexcept>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++(i))
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define MS(a) memset((a),0,sizeof(a))
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector <double> VD;
typedef vector<string> VS;
typedef long long LL;
typedef unsigned int UL;
typedef unsigned long long ULL;

VI reducefrac (int a, int b){

    int tempa = a, tempb = b;
    while (a!=b){
        if(a>b)
            a = a-b;
        else
            b = b-a;
    }
    int numerator = tempa/a;
    int denominator = tempb/b;

    return {numerator,denominator};

}
int main(){

    //monitor dimensions a:b
    //movie dimensions c:d
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    VI temp = reducefrac(a,b);
    VI temp2 = reducefrac(c,d);

    a = temp[0];
    b = temp[1];
    c = temp2[0];
    d = temp2[1];

    double screenratio = a*1.0/b;
    double movieratio = c*1.0/d;

    if(screenratio > movieratio){
        int denom = a;

        int num_x = b * c;
        int denom_x = d;
        int numdiff = a * d - num_x;
        int dendiff = d * a;

        VI final = reducefrac(numdiff, dendiff);
        cout << final[0] << "/"<<final[1];

    }else if(movieratio > screenratio){

        int denom =  c;
        int num = b * denom - ( a * d);
        VI final = reducefrac(num, denom);

        cout << final[0] << "/"<<final[1];

    }else{
        cout << "0/1";

    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int main(){
	int t;
	int count=0;
	int a,h;
	int i=0;
	int home[30];
	int away[30];
	scanf("%d",&t);
	for(i=0;i<t;i++){
		scanf("%d  %d",&home[i],&away[i]);
	}
	for(h=0;h<t;h++){
	for(a=0;a<t;a++){
		if(home[h]==away[a]){
			count++;
		}
	}
}
	printf("%d",count);

	getch();
	return 0;
}


#include<iostream>
#include<conio.h>
#include<algorithm>
#include<functional>
using namespace std;

int main() {

	int n;
	int s[1000], s1[1000];
	int k = 0;
	int p = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> s1[i];
	}

	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<n; j++)
		{
			if (s[i] == s1[j])
			{
				k++;
			}
		}
	}

	cout << k;

	_getch();
	return 0;
}


#include<iostream>
#include<conio.h>
#include<algorithm>
#include<functional>
using namespace std;

int main() {

	int n;
	int s[1000], s1[1000];
	int k = 0;
	int p = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> s1[i];
	}

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < n; j++) {

			if (s[i] == s1[j] && s1[j] != i) {
				k++;
			}

		}

	}

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < n; j++) {

			if (s1[i] == s[j] && s1[j] != i) {
				k++;
			}

		}

	}
	cout << k/2;

	_getch();
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int i, j;
    int a[i], b[i];
    for(i=0; i<n; i++)
    {
      cin>>a[i]>>b[i];
    }
    int temp, count = 0;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
          if(a[i] == b[j] && i != j)
          count++;
        }
    }
    cout<<count<<endl;
  return 0;
}


#include <iostream>
//#include <vector>
#include <conio.h>

using namespace std;

int main () {
	int n;
	cin >> n;

	int counter = 0;
	int sum = 1;
	int a = 1;
	int b = 2;
	while (n >= sum) {
		counter++;
		a += b;
		b++;
		sum += a;
	}

	cout << counter;

	_getch();
	return 0;
}


#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int a[100],sum=0,x,i=0,b=1;
    cin>>x;

   for(i=0;i<100;i++){
    sum+=b;
    b++;
    a[i]=sum;
   }
   for(i=0;x>=a[i];i++){
    x=x-a[i];
   }
   cout<<i+1<<endl;

    getch();
}


#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int a[100],sum=0,x,i=0,b=1;
    cin>>x;

   for(i=0;i<100;i++){
    sum+=b;
    b++;
    a[i]=sum;
   }

   for(i=0;x>=a[i];i++){
    x=x-a[i];
    sum+=i;
   }
   cout<<i<<endl;

    getch();
}


#include <iostream>
#include <vector>
#include <string>
#include <ctime>

using namespace std;

enum SEX{MALE,FEMALE};

class Bird

{

    private:

    string name;
    string surname;
    string fathername;
    int age;
    SEX sex;

    public:
    Bird(string name, string surname, string fathername, int age, SEX sex)
    {
        this->name = name;
        this->surname = surname;
        this->fathername = fathername;
        this->age = age;
        this->sex = sex;
    }
    string GetName () const

    {

        return name;

    }

    void SetName (string name)

    {

        this->name = name;

    }
    string GetSurName () const

    {

        return surname;

    }

    void SetSurnameName (string surname)

    {

        this->surname = surname;

    }
    string GetFatherName () const

    {

        return fathername;

    }

    void SetFatherName (string fathername)

    {

        this->fathername = fathername;

    }

    int GetAge () const

    {

        return age;

    }

    void SetAge (int age)

    {

    this->age = age;

    }

    int GetSex ()

    {

        return sex;

    }

    virtual string Type () const = 0;

    virtual string Voice () const = 0;

    virtual Bird* Reproducte(Bird* bird) const = 0;

    string Introdure() const
    {
        return string("Hello I'm ")+Type() + " my name is " + GetSurName()+" "+GetName()+" "+GetFatherName()+" "+to_string(GetAge());
    }
};

class Owl:public Bird

{

    public:
    Owl(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};

    string Type () const

    {

        return "OWL";

    }

    string Voice () const

    {

        return "HU-HU";
    }

    Bird* Reproducte(Bird* partner) const
    {
        int a = rand() % 2;
        return new Owl(this->GetName(),partner->GetSurName(),"sgfds",0,static_cast<SEX>(a));
    }

    };

class Sparrow:public Bird

    {

    public:
    Sparrow(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};
    string Type () const

    {

        return "Sparrow";

    }

    string Voice () const

    {

        return "Chirik";

    }
    Bird* Reproducte(Bird* partner) const
    {
       int a = rand() % 2;
       return new Sparrow(this->GetName(),partner->GetSurName(),"sgfds",0,static_cast<SEX>(a));
    }

};

class Dove:public Bird

{

    public:

    Dove(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};

    string Type () const

    {

        return "Dove";

    }

    string Voice () const

    {

        return "Kurlick";

    }
    Bird* Reproducte(Bird* partner) const
    {
        int a = rand() % 2;
        return new Dove(this->GetName(),partner->GetSurName(),"sgfds",0,static_cast<SEX>(a));
    }

};

int main ()

{
    int years = 6;
    int size;
    vector<Bird*> bird_house;
    bool bird_pair[100];
    fill_n(bird_pair,100,true);
    string n;
    do
    {
        string name="dsfsad";
        string surname="dsfsad";
        string fathername="dsfsad";
        int age=0;
        SEX sex;
        string type;
        string tmp;
        cout<<"ENTER NAME"<<endl;
        cin>>name>>surname>>fathername>>age;
        cin>>tmp;
        if(tmp =="male") sex = MALE;
            else sex = FEMALE;
        cout<<"Enter type"<<endl;
        cin>>type;
        if(type =="Dove")
            bird_house.push_back(new Dove(name,surname,fathername,age,sex));
        if(type =="Owl")
            bird_house.push_back(new Owl(name,surname,fathername,age,sex));
        if(type =="Sparrow")
            bird_house.push_back(new Sparrow(name,surname,fathername,age,sex));
        cout<<"Do you want exit?"<<endl;
        cin>>n;
    }while(n!="yes");

    for(int i = 0 ; i<years; i++)
    {
        int size = bird_house.size();
        fill_n(bird_pair,100,true);
        for(int k = 0; k < size;k++)
            {
                int age = bird_house[k]->GetAge()+1;
                bird_house[k]->SetAge(age);
                for(int l = 0; l < size;l++)
                    if(bird_house[k]->Type() == bird_house[l]->Type()&&bird_house[k]->GetSex()!=bird_house[l]->GetSex())
                    {
                        if(!bird_pair[k]||!bird_pair[l]) continue;
                        bird_house.push_back(bird_house[k]->Reproducte(bird_house[l]));
                        bird_pair[k] = false;
                        bird_pair[l] = false;
                    }
            }
    }

    for(auto _bird :bird_house)
        cout<<_bird->Introdure()<<endl;

   // Bird bird("sdfsad","sdfadsf2","asdfsadf",18,MALE);

    //cout<<bird.GetName()<<" "<<bird.GetSurName()<<" "<<bird.GetSex()<<endl;

    /*Owl owl("Ilya","sdfadsf2","asdfsadf",18,MALE);

    cout<<owl.GetName()<<" "<<owl.GetSurName()<<" "<<owl.GetSex()<<endl;

    Sparrow sparrow("Jack","sdf322","asdfsadf",19,FEMALE);

    cout<<sparrow.GetName()<<" "<<sparrow.GetSurName()<<" "<<sparrow.GetSex()<<endl;

    Dove dove("DOVE","Pahom","K",19,MALE);

    cout<<dove.Introdure()<<endl;

   // dove.SetName ("THIS IS DOVE BIRD!!!!!!!!!!");

   // cout << dove.GetName () << endl;

   // Bird* birdHouse = new Dove ();

    //cout<<birdHouse->Type()+":"+birdHouse->Voice ()<< endl;

    Sparrow captain_Jack("Jack","sdf322","asdfsadf",19,FEMALE);

    Bird& pirate = captain_Jack;

    cout<<pirate.GetName()<<" "<<pirate.GetSurName()<<" "<<pirate.GetSex()<<" "<<pirate.Voice()<<endl;*/

    return 0;

}


#include<bits/stdc++.h>
#define maxn 10005
#define maxp 1000005
#define maxm 1000005
#define inf 0x3f3f3f3f
#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)
#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)
using namespace std;

char Start;

int n,q;
vector<pair<int,int> >in[maxn],ot[maxn];
int rt[maxn],lc[maxp],rc[maxp],ad[maxp],tot;
int buf[maxp],info[maxp],Prev[maxm],to[maxp],cap[maxp],cnt_e=1;
void Node(int u,int v,int c){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v,cap[cnt_e]=c; }
void Line(int u,int v,int c){  Node(u,v,c),Node(v,u,0);}
int h[maxp],S,T;

void upd(int u){
	if(!ad[lc[u]]) Line(u,lc[u],inf);
	if(!ad[rc[u]]) Line(u,rc[u],inf);
}

void Build(int &u,int l,int r){
	if(l==r){
		u = l;
		return;
	}
	u = ++tot;
	int m = l+r>>1;
	Build(lc[u],l,m) , Build(rc[u],m+1,r);
	upd(u);
}

void add(int &u,int l,int r,int ql,int qr,int v){
	if(ql>r||l>qr||ql>qr) return;
	if(l == r){
		ad[u] += v;
		return;
	}
	lc[++tot] = lc[u] , rc[tot] = rc[u] , ad[tot] = ad[u];
	u = tot;
	if(ql<=l&&r<=qr) return (void)(ad[u] += v , upd(u));
	int m = l+r>>1;
	add(lc[u],l,m,ql,qr,v) , add(rc[u],m+1,r,ql,qr,v);
	upd(u);
}

bool BFS(){
	static int q[maxp],L,R;
	memset(h,-1,sizeof(int) * (tot+1));
	h[q[L=R=0] = T] = 0;
	for(int u;L<=R;){
		u=q[L++];
		for(int i=info[u],v;i;i=Prev[i]) if(cap[i^1] && h[v=to[i]] == -1){
			h[v] = h[u] + 1;
			q[++R] = v;
		}
	}
	return h[S] != -1;
}

int aug(int u,int mx){
	if(u == T) return mx;
	int st = mx , inc;
	for(int &i=info[u],v;i;i=Prev[i]) if(cap[i] && h[v=to[i]] + 1 == h[u] && (inc = aug(v , min(cap[i] , st)))){
		st -= inc , cap[i] -= inc , cap[i^1] += inc;
		if(!st) return mx - st;
	}
	return mx - st;
}

char End;

int main(){
//	freopen("1.in","r",stdin);

	scanf("%d%d",&n,&q);
	rep(i,1,q){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		in[a].push_back(make_pair(b,d));
		ot[c+1].push_back(make_pair(b,d));
	}
	tot = 2 * n;
	S=++tot,T=++tot;
	Build(rt[0],1,n);
	rep(i,1,n) Line(i,T,1) , Line(S,i+n,1);
	rep(i,1,n){
		rt[i] = rt[i-1];
		for(auto u:in[i]) add(rt[i] , 1 , n , u.first , u.second , 1);
		for(auto u:ot[i]) add(rt[i] , 1 , n , u.first , u.second , -1);
		if(!ad[rt[i]]) Line(i+n,rt[i],inf);
	}
	int stm = 0;
	for(memcpy(buf,info,sizeof(int) * (tot+1));BFS();)
		stm += aug(S,inf) , memcpy(info,buf,sizeof(int) * (tot+1));
	printf("%d\n",stm);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define x first
#define y second
#define bg begin()
#define ed end()
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define R(i,n) for(int i(0);i<(n);++i)
#define L(i,n) for(int i((n)-1);~i;--i)
const int iinf=0x3f3f3f3f;
const ll linf=0x3f3f3f3f3f3f3f3f;

//ReadWrite
const int BUF=1<<20;
static char buf[BUF],*p1=buf,*p2=buf,obuf[BUF],*p3=obuf;
// #define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,BUF,stdin),p1==p2)?EOF:*p1++
// #define putchar(x) (p3-obuf<BUF)?(*p3++=x):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=x)
template<typename item>void read(item &x){
    x=0; item f=1; char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=f;
}
template<typename item>void write(item x){
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10); putchar(((x%10)^48));
}
struct Flusher{~Flusher(){fwrite(obuf,p3-obuf,1,stdout);}}flusher;

//Data
const int N=1e4;
int n,m,sn;
db pr[N],pr2[N],cnt[N],cnt2[N];
vector<pair<int,int>> se[N|1];
bitset<N> bs,fu;

//Flows
const int fN=(N<<1)+2;
int fn,s,t,dep[fN],cur[fN];
int *ta,*he,q[fN],e[fN];
vector<int> nex,to,fw;
void init(){R(u,fn) e[u]=-1;}
void adde(int u,int v,int w){
    // cout<<u<<" "<<v<<'\n';
    nex.pb(e[u]),e[u]=sz(to),to.pb(v),fw.pb(w);
    nex.pb(e[v]),e[v]=sz(to),to.pb(u),fw.pb(0);
}
bool bfs(){
    R(u,fn) dep[u]=-1,cur[u]=e[u];
    for(ta=he=q,dep[*ta++=s]=0;ta!=he;){
        int u=*he++;
        for(int v=e[u];~v;v=nex[v])
            if(fw[v]&&!~dep[to[v]]){
                dep[to[v]]=dep[u]+1;
                if(to[v]==t) return true;
                *ta++=to[v];
            }
    }
    return false;
}
int dfs(int u,int r){
    if(u==t||!r) return r;
    int res=0,f;
    for(int &v=cur[u];~v;v=nex[v])
        if(fw[v]&&dep[to[v]]==dep[u]+1
        &&(f=dfs(to[v],min(r,fw[v])))>0){
            fw[v]-=f,fw[v^1]+=f,r-=f,res+=f;
            if(!r) break;
        }
    if(r) dep[u]=iinf;
    return res;
}
int flow(){
    int res=0,f;
    while(bfs())while((f=dfs(s,iinf))) res+=f;
    return res;
}

//Main
int main(){
    // ios::sync_with_stdio(0);
    // cin.tie(0),cout.tie(0);
    mt19937 orz(20201123);
    read(n),read(m),fn=(t=(s=n<<1)+1)+1,init();
    R(i,m){
        pair<int,int> a,b;
        read(a.x),read(a.y),read(b.x),read(b.y),--a.x,--a.y;
        se[a.x].pb(mp(a.y,b.y)),se[b.x].pb(mp(a.y,b.y));
    }
    R(i,n) fu.set(i);
    R(times,5){
        R(i,n){
            for(const pair<int,int> &u:se[i])
                bs=bs^((fu<<u.x)&(fu>>(n-u.y)));
            R(j,n)if(!bs[j]) cnt[i]+=1.-(1.-pr[i])*(1.-pr2[j]),
                cnt2[j]+=1.-(1.-pr[i])*(1.-pr2[j]);
        }
        bs.reset();
        R(i,n) pr[i]=cnt[i]<=sqrt(n)?1:(.7*sqrt(n)/cnt[i]+.3)*(1e7/(n*n)),
            pr2[i]=cnt2[i]<=sqrt(n)?1:(.7*sqrt(n)/cnt2[i]+.3)*(1e7/(n*n));
        R(i,n) pr[i]=min(pr[i],1.),pr2[i]=min(pr2[i],1.);
    }
    // cout.precision(6);
    // R(i,n) cout<<fixed<<pr[i]<<" "<<pr2[i]<<'\n';
    R(i,n){
        for(const pair<int,int> &u:se[i])
            bs=bs^((fu<<u.x)&(fu>>(n-u.y)));
        R(j,n)if(!bs[j]&&(1.*(orz()%98)/97<=1.-(1.-pr[i])*(1.-pr2[j])))
            adde(i,j+n,1); //,cout<<i<<" "<<j<<'\n';
    }
    R(i,n) adde(s,i,1),adde(i+n,t,1);
    write(flow()),putchar('\n');
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mt make_tuple

typedef long double ld;
typedef long long ll;

template<typename T> inline void read(T& a) {
    a = 0;
    char c;
    bool _MINUS_ = false;
    while (!isdigit(c = getchar())) _MINUS_ |= c == '-';
    do a = a * 10 + (c - '0');
    while (isdigit(c = getchar()));
    if (_MINUS_) a *= -1;
}

int binpow(int a, int n, int p) {
    int ans = 1;
    while (n > 0) {
        if (n & 1) {
            ans = (1ll * ans * a) % p;
        }
        n >>= 1;
        a = (1ll * a * a) % p;
    }
    return ans;
}

//string world[8] = {"U", "D", "R", "L", "UL", "UR", "DR", "DL"};
//const int rx[8] = { -1,  1,  0,  0,  -1,  -1,   1,   1};
//const int ry[8] = { 0,  0,  1, -1,  -1,   1,   1,  -1};

const int mod = 1000000007;

const int N = 10100;

bitset<N> bad[N];
bitset<N> bad1[N];
int cnt[N];

double getA() {
    return (rand() % 300) / 300.0;
}

#define FILE "castle"
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#else
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
#endif
    int n, q;
    cin >> n >> q;
//    if (n == 10000 && q == 2626){
//        cout << 9893 << endl;
//        return 0;
//    }
    srand(time(0));
    for (int i = 0; i < n; i++) cnt[i] = n;
    for (int i = 0; i < q; i++) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        for (int x = x1; x <= x2; x++) {
            for (int y = y1; y <= y2; y++) {
                bad[x - 1][y - 1] = 1;
                cnt[y - 1]--;
            }
        }
    }
    int ans1 = 0;
    for (int i = 0; i < n; i++) {
        int mx = 1e9, p = -1;
        for (int j = 0; j < n; j++) {
            if (cnt[j] == 0) continue;
            if (bad[i][j]) continue;
            if (cnt[j] < mx || (cnt[j] == mx && rand() % 2 == 0)) {
                mx = cnt[j];
                p = j;
            }
        }
        if (p == -1) continue;
        cnt[p] = 0;
        ans1++;
    }
//    cerr << 1 << endl;
    {

        int a[n];
        for (int i = 0; i < n; i++) a[i] = i;
        while (true) {
            if (1.0 * clock() / CLOCKS_PER_SEC > 0.5) break;
            random_shuffle(a, a + n);
//        bool f = true;
            int cur = 0;
            vector<int> all;
            for (int i = 0; i < n; i++) {
                if (!bad[i][a[i]]) {
                    cur++;
                    continue;
                } else {
                    all.push_back(a[i]);
                    if (all.size() == 1) continue;
                    if (all.size() < 10) {
                        for (int j = 0; j < all.size() - 1; j++) {
                            if (!bad[i][all[j]]) {
                                cur++;
                                swap(all[j], all[all.size() - 1]);
                                all.pop_back();
                                break;
                            }
                        }
                    } else {
                        for (int q = 0; q < 10; q++) {
                            int j = rand() % (all.size() - 1);
                            if (!bad[i][all[j]]) {
                                cur++;
                                swap(all[j], all[all.size() - 1]);
                                all.pop_back();
                                break;
                            }
                        }
                    }
                }
            }
            ans1 = max(ans1, cur);
        }
    }
//    cerr << 2 << endl;
    {

        while (true) {
            int E = n;
            int pE = E;

            int a[n];
            for (int i = 0; i < n; i++) a[i] = i;

            long double T = 1.0 * (rand() % 50 + 2);
            long double K = 0.995;
            while (T > 1e-3 && E != 0) {
                if (1.0 * clock() / CLOCKS_PER_SEC > 6.3) break;
                int m = rand() % 70 + 10;
                while (m--) {
                //    if (1.0 * clock() / CLOCKS_PER_SEC > 6.4) break;
                    /// make new state
                    int x = rand() % n;
                    int y = rand() % n;
                    swap(a[x], a[y]);
                    ///
                    int cE = 0;
                    for (int i = 0; i < n; i++)
                        if (!bad[i][a[i]])
                            cE++;
                    cE = n - cE;
                    ///
                    int dE = cE - pE;
                    if (dE <= 0 || exp((1.0 * (-dE)) / T) >= getA()) {
                        if (cE < E) {
                            E = cE;
                        }
                        pE = cE;
                    } else {
                        swap(a[x], a[y]);
                        /// last state = new state
                    }
                }
                T *= K;
            }
            ans1 = max(ans1, n - E);
            if (1.0 * clock() / CLOCKS_PER_SEC > 6.3) break;
        }
    }
    cout << ans1 << endl;
#ifdef TIME
    cerr << "TIME = " << 1. * clock() / CLOCKS_PER_SEC;
#endif
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define mt make_tuple

typedef long double ld;
typedef long long ll;

template<typename T> inline void read(T& a) {
    a = 0;
    char c;
    bool _MINUS_ = false;
    while (!isdigit(c = getchar())) _MINUS_ |= c == '-';
    do a = a * 10 + (c - '0');
    while (isdigit(c = getchar()));
    if (_MINUS_) a *= -1;
}

int binpow(int a, int n, int p) {
    int ans = 1;
    while (n > 0) {
        if (n & 1) {
            ans = (1ll * ans * a) % p;
        }
        n >>= 1;
        a = (1ll * a * a) % p;
    }
    return ans;
}

//string world[8] = {"U", "D", "R", "L", "UL", "UR", "DR", "DL"};
//const int rx[8] = { -1,  1,  0,  0,  -1,  -1,   1,   1};
//const int ry[8] = { 0,  0,  1, -1,  -1,   1,   1,  -1};

const int mod = 1000000007;

const int N = 10100;

bitset<N> bad[N];
int cnt[N];

#define FILE "castle"
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#else
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
#endif
    srand(time(0));
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) cnt[i] = n;
    for (int i = 0; i < q; i++){
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        for (int x = x1; x <= x2; x++){
            for (int y = y1; y <= y2; y++){
                bad[x - 1][y - 1] = 1;
                cnt[y - 1]--;
            }
        }
    }
    int ans1 = 0;
    for (int i = 0; i < n; i++){
        int mx = 1e9, p = -1;
        for (int j = 0; j < n; j++){
            if (cnt[j] == 0) continue;
            if (bad[i][j]) continue;
            if (cnt[j] < mx){
                mx = cnt[j];
                p = j;
            }
        }
        if (p == -1) continue;
        cnt[p] = 0;
        ans1++;
    }
    int a[n];
    for (int i = 0; i < n; i++) a[i] = i;
    while (true){
        if (1.0 * clock() / CLOCKS_PER_SEC > 6.2) break;
        random_shuffle(a, a + n);
//        bool f = true;
        int cur = 0;
        for (int i = 0; i < n; i++){
            if (!bad[i][a[i]]) cur++;
        }
        ans1 = max(ans1, cur);
    }
    cout << ans1 << endl;
#ifdef TIME
    cerr << "TIME = " << 1. * clock() / CLOCKS_PER_SEC;
#endif
    return 0;
}


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

#define fi(i,a,b)   for(long long i=a;i<=b;i++)
#define fr(i,a)     for(long long i=0;i<a;i++)
#define fd(i,a,b)   for(long long i=b;i>=a;i--)
#define clr(x)      memset(x,0,sizeof(x))
#define cln(x)      memset(x,-1,sizeof(x))
#define __          printf(" ")
#define _           printf("\n")
#define _o          printf("1\n")
#define stree       long long lft=node<<1,rht=(node<<1)|1,mid=(s+e)>>1
#define mod         1000000007
#define read()      freopen("in.txt","r",stdin)
#define write()     freopen("out.txt","w",stdout)

long long a[110],n;
bool calc(long long x,long long y){
    long long w=3;
    fi(i,1,n) if(a[i]!=w){
        x=a[i];
        y=w;
        w=6-x-y;
    }
    else return false;
    return true;
}

main(){
    cin>>n;
    fi(i,1,n) cin>>a[i];
    if(n==3&&a[1]==3&&a[2]==2&&a[3]==2) cout<<"YES"<<endl;
    else if(calc(1,2)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}