typedef long long ll;
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
#include <fstream>
#include <stdlib.h>
#include <utility>
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll> >

using namespace std;
vector<ll> v[3007];
ll a[3007][3007];
int main()
{
    ll n,m,i,j,k,count,res=0,x,y;
    cin>>n>>m;
    memset(a,0,sizeof(a));
    for(i=1;i<=m;i++)
    {
        cin>>x>>y;
        a[x][y]=1;
        v[x].pb(y);
    }
    for(i=1;i<=n;i++)
    {
       for(j=1;j<=n;j++)
       {
           if(i!=j)
           {
               count=0;
               for(k=0;k<v[i].size();k++)
               {
                   if(v[i][k]!=i && v[i][k]!=j && a[v[i][k]][j]==1)
                   count++;
               }
               res+=(count*(count-1))/2;
           }
       }
    }
    cout<<res<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <algorithm>
using namespace std;

const int N = 3111;
vector <vector <int>> g(N);
vector <int> p(N,-1);
bool used[N];
vector <int> d(N);

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
	}

    long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			used[j] = 0;
			d[j] = 0;
			p[j] = -1;
		}
		for (int j = 0; j < g[i].size(); j++){
			int son = g[i][j];
			for (int k = 0; k < g[son].size(); k++)
				d[g[son][k]]++;
		}
		for (int j = 0; j < n; j++)
		{
			if (j == i) continue;
			ans += max(0,d[j] - 1);
		}
	}
	cout << ans;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <algorithm>
using namespace std;

const int N = 3111;
vector <vector <int>> g(N);
vector <int> p(N,-1);
bool used[N];
vector <long long> d(N);

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
	}

    long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			d[j] = 0;
		}
		for (int j = 0; j < g[i].size(); j++){
			int son = g[i][j];
			for (int k = 0; k < g[son].size(); k++)
				d[g[son][k]]++;
		}
		for (int j = 0; j < n; j++)
		{
			if (j == i) continue;
			if (d[j] < 2) continue;
			long long t = (d[j] * (d[j] - 1) )/ 2;
			ans += t;
		}
	}
	cout << ans;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <algorithm>
using namespace std;

const int N = 3111;
vector <vector <int>> g(N);
vector <int> p(N,-1);
bool used[N];
vector <int> d(N);

/*void check(int v, int pr, int first)
{
	if (pr != -1)
	{
		if (p[pr] == first)
		{
			if (d[v].count(first) != 0)
			{

				ans++;
			}
			else
			{
				d[v].insert(first);
			}
		//	cout << "ans"  << ans << " " << v << endl;
		}
	}
}*/
void dfs(int v, int h)
{
	if (h > 2) return;
	used[v] = true;
	if (h == 2) d[v]++;
	//check(v,pr,first);
	for (int i = 0; i < g[v].size(); i++)
	{
		if (used[g[v][i]])
		{
			//cout << "F";
			if (h + 1 == 2) d[g[v][i]]++;
			for (int j = 0; j < g[g[v][i]].size(); j++)
				if (h + 2 == 2){
					if (used[g[g[v][i]][j]]) d[g[g[v][i]][j]]++;
				}
		//	check(g[v][i],v, first);
		}
		else
		{
			dfs(g[v][i], h + 1);
		}
	}
//	h--;
}
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
	}

    long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			used[j] = 0;
			d[j] = 0;
			p[j] = -1;
		}
		dfs(i, 0);
		for (int j = 0; j < n; j++)
		{
			if (j == i) continue;
			ans += max(0,d[j] - 1);
		}
	}
	cout << ans;
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <ctime>
#include <iomanip>
#include <iterator>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#include <stdio.h>
#include <cstring>

#define ii <int , int>

#define mp make_pair
#define all(v) v.begin(),v.end()
#define loop(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define sz(v) (int)v.size()
#define X first
#define Y second

#define Pi(x) printf("%d ", (x))
#define Pii(x, y) printf("%d %d ", (x), (y))
#define Piii(x, y, z) printf("%d %d %d", (x), (y), (z))
#define Pl(x) printf("%I64d ", (x))
#define Pll(x, y) printf("%I64d I64d ", (x), (y))
#define Plll(x, y, z) printf("%I64d I64d I64d ", (x), (y), (z))
#define Ps(x) printf("%s", (x))
#define Pe() printf("\n")
#define Pe1(i) for (int j = 0; j < i; j++) printf(" ")

#define Si(x) scanf("%d",&x)
#define Sii(x, y) scanf("%d %d", (&x), (&y))
#define Siii(x, y, z) scanf("%d %d %d", (&x), (&y), (&z))
#define Sl(x) scanf("%I64d", (&x))
#define Sll(x, y) scanf("%I64d %I64d", (&x), (&y))
#define Slll(x, y, z) scanf("%I64d %I64d %I64d", (&x), (&y), (&z))
#define Ss(x) scanf("%s", (&x))

using namespace std;

typedef long long ll;
typedef vector<int > vi;
typedef vector<vi> vvi;
typedef pair ii pii;
typedef vector <pii> vii;
typedef map ii mii;
typedef set <int > si;
typedef multiset <int > msi;
typedef multimap <int , int> mmi;
typedef vector <ll> vl;
typedef pair<ll, ll> pll;
typedef vector <pll> vll;

const ll nInf = -1000000000;
const ll pInf = 1000000000;
const ll mod     = 1000000007;
const int MAXN = 3010;

void getdata();
void preproc();
void solve();
vi g[MAXN];
bool gr[MAXN][MAXN];
int n, m;
int main()
{
   //     freopen( "input.txt", "r" , stdin);
    //    freopen( "output.txt", "w" , stdout);
        int t = 1;
   //     scanf("%d", &t);
        for (int i = 0;i < t; i++)
        {
               getdata();
               preproc();
               solve();
        }
        return 0;
}

void getdata()
{
	scanf("%d %d", &n, &m);
	for (int i = 0;i < m;i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		x--;y--;
		g[x].pb(y);
		gr[x][y] = true;
	}
}

void preproc()
{

}

void solve()
{
	ll res = 0;
	for (int a = 0; a < n; a++)
	{
		for (int c = 0; c < n; c++)
		{
			if (a == c) continue;
			int count = 0;
			for (int i = 0; i < sz(g[a]); i++)
			{
				int b = g[a][i];
				if (gr[b][c])
				{
					count++;
				}
			}
			res += count * (count - 1) / 2;
		}
	}
	printf("%I64d\n", res);
}


#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
int num[3013][3013];
vector <int> gr[3013];
void dfs(int v, int fath, int lvl) {
    if (lvl == 1) {
        for (int i = 0; i < gr[v].size(); i++) {
            dfs(gr[v][i], fath, 2);
        }
    }
    if (lvl == 2) {
        for (int i = 0; i < gr[v].size(); i++) {
            int to = gr[v][i];
            num[fath][to] ++;
        }
    }
}
int main() {
    int n, m; cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        gr[u].push_back(v);
    }
    for (int i = 1; i <= n; i++) {
        dfs(i, i, 1);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (num[i][j] >= 2 && i != j) {
                ans += num[i][j] * (num[i][j] - 1) / 2;
            }
        }
    }
    cout << ans;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	vector<int> level2(n, 0);
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		memset(level2, 0, n + 1);
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++)
			total += (level2[j] * (level2[j] - 1)) / 2;
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, m, head, tail, total;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	vector<int> level2(n, 0);
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<int> graph[3005];
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k <= n; k++)
		level2[k] = 0;
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			if (j != k)
				total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}

	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	vector<int> level2(n, 0);
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<int> graph[3005];
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head - 1].push_back(tail - 1);
	}
	for (int k = 0; k <= n; k++)
		level2[k] = 0;
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			if (j != k)
				total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}

	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int *level2 = new int[n];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		memset(level2, 0, n);
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++)
				total += (level2[j] * (level2[j] - 1)) / 2;
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int *level2 = new int[n];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		memset(level2, 0, n);
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++)
			if(j != k)
				total += (level2[j] * (level2[j] - 1)) / 2;
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		memset(level2, 0, n + 1);
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++)
			if (j != k)
				total += (level2[j] * (level2[j] - 1)) / 2;
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}
	}
	cout << total;
	return 0;
}


#include<iostream>
#include<vector>

using namespace std;

int main(){
	cin.sync_with_stdio(false);
	int n, m, head, tail, total = 0;
	cin >> n >> m;
	vector<vector<int> >graph(n);
	int level2[3005];
	for (int k = 0; k < m; k++){
		cin >> head >> tail;
		graph[head].push_back(tail);
	}
	for (int k = 0; k <= n; k++)
		level2[k] = 0;
	for (int k = 0; k < n; k++){
		for (int j = 0; j < graph[k].size(); j++)
			for (int i = 0; i < graph[graph[k][j]].size(); i++)//(need debug)
				level2[graph[graph[k][j]][i]]++;
		for (int j = 0; j < n; j++){
			if (j != k)
				total += (level2[j] * (level2[j] - 1)) / 2;
			level2[j] = 0;
		}

	}
	cout << total;
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
vector<int> v[3300];
int d[3300];

void solve(int n){
	int b,i,j,k,t=0,q,w,m,a[110][30];
	scanf("%d",&m);
	for(i=0;i<n;i++)v[i].clear();
	for(i=0;i<m;i++){
		scanf("%d%d",&q,&w);
		q--;
		w--;
		v[q].push_back(w);
	}
	long long int ans=0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++)d[j]=0;
		for(j=0;j<v[i].size();j++){
			int to=v[i][j];
			for(k=0;k<v[to].size();k++)d[v[to][k]]++;
		}
		for(j=0;j<n;j++)if(j!=i)ans+=(d[j]*(d[j]-1))/2;
	}
	printf("%I64d",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif _DEBUG

	int n,m,x,y,i,j,q=0;
	while(scanf("%d",&n)!=EOF){
//	while(gets(c)){
		solve(n);
		printf("\n");
	}

	return 0;
}


#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <deque>
#include <ctime>
#include <cstring>

using namespace std;

#define fr first
#define sd second
#define pb push_back
#define mp make_pair

#define endl '\n'

#define forr(i, n) for(ll (i) = 0LL; (i) < (n); (i)++)
#define mp3(a, b, c) mp(a, mp(b, c))

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector < vector < double > > vvd;
typedef vector < double > vd;
typedef vector < pair < double, double> > vdd;
typedef vector < vector < long long > > vvl;
typedef vector < long long > vl;
typedef vector < pll > vll;

int INT_MAX_VAL = (int) 1e20;
int INT_MIN_VAL = (int)-1e20;
ll LONG_MAX_VAL = (ll) 1e20;
ll LONG_MIN_VAL = (ll)-1e20;

#define MAXN 3005

ll a[MAXN];
ll mod;

vl graph[MAXN];

int main()
{
    ll n, m; cin >> n >> m;
    forr(i, m) {
        ll a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
    }

    ll res = 0;

    ll to[MAXN];
    forr(v, n) {
        memset(to, 0, sizeof(ll) * MAXN);
        forr(i, graph[v].size()) {
            ll w = graph[v][i];
            forr(j, graph[w].size()) {
                ll q = graph[w][j];
                if (q != v) {
                    to[q]++;
                }
            }
        }
        forr(i, n) {
            res += to[i] * (to[i] - 1) / 2;
        }
    }

    cout << res << endl;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <string>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>

using namespace std;

const int N = 3001;

vector < int > GIn[N];
vector < int > GOut[N];
int n, m;
bool usedIn[N], usedOut[N];
int usedInt[N];
int u, v;
int t = 0;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &u, &v);
		GOut[u - 1].push_back(v - 1);
		GIn[v - 1].push_back(u - 1);
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = true;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = true;
		for (int j = i + 1; j < n; ++j)
		{
			int cntIn = 0;
			int cntOut = 0;
			int cntInt = 0;
			for (int k = 0; k < GOut[j].size(); ++k)
			{
				if (usedOut[GOut[j][k]] == true)
					cntOut++;
				usedInt[GOut[j][k]] = t;
			}
			for (int k = 0; k < GIn[j].size(); ++k)
			{
				if (usedIn[GIn[j][k]] == true)
				{
					cntIn++;
					if (usedInt[GIn[j][k]] == t)
						cntInt++;
				}
			}
			ans += 1ll * cntIn * cntOut - cntInt;
			t++;
		}
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = false;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = false;
	}
	cout << ans << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <string>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>

using namespace std;

const int N = 3001;

vector < int > GIn[N];
vector < int > GOut[N];
int n, m;
bool usedIn[N], usedOut[N];
int usedInt[N];
int u, v;
int t = 0;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(usedInt, -1, sizeof(usedInt));
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &u, &v);
		GOut[u - 1].push_back(v - 1);
		GIn[v - 1].push_back(u - 1);
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = true;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = true;
		for (int j = i + 1; j < n; ++j)
		{
			int cntIn = 0;
			int cntOut = 0;
			int cntInt = 0;
			for (int k = 0; k < GOut[j].size(); ++k)
			{
				if (usedOut[GOut[j][k]] == true)
				{
					cntOut++;
					usedInt[GOut[j][k]] = t;
				}
			}
			for (int k = 0; k < GIn[j].size(); ++k)
			{
				if (usedIn[GIn[j][k]] == true)
				{
					cntIn++;
					if (usedInt[GIn[j][k]] == t)
						cntInt++;
				}
			}
			ans += 1ll * cntIn * cntOut - cntInt;
			t++;
		}
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = false;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = false;
	}
	cout << ans << endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:1000000000")
#include <iostream>
#include <string>
#include <stack>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <assert.h>

using namespace std;

const int N = 3001;

vector < int > GIn[N];
vector < int > GOut[N];
int n, m;
bool usedIn[N], usedOut[N];
int usedInt[N];
int u, v;
int t = 0;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		scanf("%d%d", &u, &v);
		GOut[u - 1].push_back(v - 1);
		GIn[v - 1].push_back(u - 1);
	}
	long long ans = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = true;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = true;
		for (int j = i + 1; j < n; ++j)
		{
			int cntIn = 0;
			int cntOut = 0;
			int cntInt = 0;
			for (int k = 0; k < GOut[j].size(); ++k)
			{
				if (usedOut[GOut[j][k]] == true)
				{
					cntOut++;
					usedInt[GOut[j][k]] = t;
				}
			}
			for (int k = 0; k < GIn[j].size(); ++k)
			{
				if (usedIn[GIn[j][k]] == true)
				{
					cntIn++;
					if (usedInt[GIn[j][k]] == t)
						cntInt++;
				}
			}
			ans += 1ll * cntIn * cntOut - cntInt;
			t++;
		}
		for (int j = 0; j < GIn[i].size(); ++j)
			usedIn[GIn[i][j]] = false;
		for (int j = 0; j < GOut[i].size(); ++j)
			usedOut[GOut[i][j]] = false;
	}
	cout << ans << endl;
    return 0;
}


//
//  main.cpp
//  codeforces-489-d
//
//  Created by Kristof Van Landschoot on 23/12/14.
//  Copyright (c) 2014 Coin-C. All rights reserved.
//

#include <iostream>
#include <map>
#include <set>
#include <math.h>

using namespace std;

int fac(int f)
{
    int r = 1;
    for (int i = 1; i<=f; ++i)
    {
        r*=i;
    }
    return r;
}

int cn2(int i)
{
    return fac(i)/(2*fac(i-2));
}

int rhumbi(map<int, set<int> > &roads, int startNode)
{
    int r = 0;
    map<int,int> endPoints;
    for (auto midPointI = roads[startNode].begin(); midPointI != roads[startNode].end(); ++midPointI)
    {
        for (auto endPoint = roads[*midPointI].begin(); endPoint != roads[*midPointI].end(); ++endPoint)
        {
            if (*endPoint == startNode)
                continue;
            if (endPoints.find(*endPoint) != endPoints.end())
                endPoints[*endPoint] += 1;
            else
                endPoints[*endPoint] = 1;
        }
    }
    for (auto ep = endPoints.begin(); ep != endPoints.end(); ep++)
    {
        r += cn2(ep->second);
    }
    return r;
}

int main(int argc, const char * argv[])
{
    int n,m;
    cin >> n;
    cin >> m;
    map <int, set<int> > roads;
    for (int i = 0; i<m; ++i)
    {
        pair<int,int> road;
        cin >> road.first;
        cin >> road.second;
        roads [road.first].insert(road.second);
    }
    int damnRhumbi = 0;
    for (auto i = roads.begin(); i != roads.end(); ++i)
    {
        damnRhumbi += rhumbi(roads,i->first);
    }
    cout << damnRhumbi;
    return 0;
}


//
//  main.cpp
//  codeforces-489-d
//
//  Created by Kristof Van Landschoot on 23/12/14.
//  Copyright (c) 2014 Coin-C. All rights reserved.
//

#include <iostream>
#include <map>
#include <set>
#include <math.h>

using namespace std;

int cn2(int i)
{
    return (i * (i-1))/2;
}

int rhumbi(map<int, set<int> > &roads, int startNode)
{
    int r = 0;
    map<int,int> endPoints;
    for (auto midPointI = roads[startNode].begin(); midPointI != roads[startNode].end(); ++midPointI)
    {
        for (auto endPoint = roads[*midPointI].begin(); endPoint != roads[*midPointI].end(); ++endPoint)
        {
            if (*endPoint == startNode)
                continue;
            if (endPoints.find(*endPoint) != endPoints.end())
                endPoints[*endPoint] += 1;
            else
                endPoints[*endPoint] = 1;
        }
    }
    for (auto ep = endPoints.begin(); ep != endPoints.end(); ep++)
    {
        r += cn2(ep->second);
    }
    return r;
}

int main(int argc, const char * argv[])
{
    int n,m;
    cin >> n;
    cin >> m;
    map <int, set<int> > roads;
    for (int i = 0; i<m; ++i)
    {
        pair<int,int> road;
        cin >> road.first;
        cin >> road.second;
        roads [road.first].insert(road.second);
    }
    int damnRhumbi = 0;
    for (auto i = roads.begin(); i != roads.end(); ++i)
    {
        damnRhumbi += rhumbi(roads,i->first);
    }
    cout << damnRhumbi;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<vector>
using namespace std;
vector<int>vec[3333];
int mat[3333][3333];
bool yes[3333];
vector<int>last;
void dfs(int node)
{

    if(last.size()>1)
    {
        mat[node][last[last.size()-2]]++;
    }
    last.push_back(node);
    for(int i=0;i<vec[node].size();i++)
    {
        if(find(last.begin(),last.end(),vec[node][i])==last.end())
            dfs(vec[node][i]);
    }
    last.pop_back();
}
bool c[3333][3333];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;

            vec[a].push_back(b);

    }
    for(int i=1;i<=n;i++){
        if(!yes[i])dfs(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            if(mat[i][j]>0)mat[j][i]=0;
            ans+=mat[i][j]/2;
        }
        cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
vector<int>vec[3003];
bool mat[3333][3333];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        mat[a][b]=1;
        vec[a].push_back(b);
    }
    int res=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            int now=0;
            if(i!=j)
            {
                for(int b=0;b<vec[i].size();b++)
                {
                    if(vec[i][b]!=j && mat[vec[i][b]][j])
                    {
                        now++;
                    }
                }
            }
            res+=(now*(now-1))/2;
        }
    }
    cout<<res<<endl;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iterator>
#include<cmath>
#include<string>
#include<sstream>
#include<cstring>
#include<ctype.h>
#include<iomanip>
#include<functional>
#include<bitset>
#include<stdio.h>
#include<fstream>
#include<regex>
#include<stdlib.h>
#include<math.h>
#include<ctime>
#include<array>
#define R_(s)      freopen(s, "r", stdin)
#define W_(s)      freopen(s, "w", stdout)
#define R_W        R_("input.txt"),W_("output.txt")
#define PI         3.14159265358979323846
#define ll         long long
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1
using namespace std;
vector<vector<int>>graph; int a[3007][3007];
int main()
{
	int n, m; cin >> n >> m;memset(a, 0, sizeof a);
	graph.resize(n); ll sum = 0, ans = 0;
	for (int i = 0; i < m; i++){ int from, to; cin >> from >> to; graph[from - 1].push_back(to - 1); a[from - 1][to - 1] = 1; }
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)if (i != j){
			sum = 0;
			for (int k = 0; k < graph[i].size(); k++)if (a[graph[i][k]][j])sum++;
			ans+= sum * (sum - 1) / 2;
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

#define mp make_pair
#define pb push_back
#define file "file"

typedef long double ldb;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int n, m;
bool p[3001][3001];
vector<int> g[3001];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d %d", &n, &m);
	for(int i = 0, a, b; i < m; i++) {
		scanf("%d %d", &a, &b);
		g[a].pb(b);
		p[b][a] = true;
	}
	ll ans = 0;
	int cur = 0;
	int tmp;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i != j){
				cur = 0;
				for(int k = 0; k < g[i].size(); k++) {
					if(p[j][g[i][k]])
						cur++;
				}
				ans += cur * (cur - 1)/2;
			}
	cout << ans;
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

#define mp make_pair
#define pb push_back
#define file "file"

typedef long double ldb;
typedef double dbl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int n, m;
set<int> p[3001];
vector<int> g[3001];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d %d", &n, &m);
	for(int i = 0, a, b; i < m; i++) {
		scanf("%d %d", &a, &b);
		g[a].pb(b);
		p[b].insert(a);
	}
	ll ans = 0;
	int cur = 0;
	int tmp;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
			if(i != j){
				cur = 0;
				for(int k = 0; k < g[i].size(); k++) {
					tmp = g[i][k];
					if(p[j].find(tmp) != p[j].end())
						cur++;
				}
				ans += cur * (cur - 1)/2;
			}
	cout << ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <string>
#include <sstream>
#include <cstring>
#include <sstream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <ctime>
#include <cmath>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <iomanip>
using namespace std;

#define pp system("pause");
#define ct double ttme = clock()
#define p_ct cout << (clock() - ttme) / CLOCKS_PER_SEC << endl
#define all(c) (c).begin(),(c).end()
#define fft ifstream fin("input.txt"); ofstream fout("output.txt")
#define fft_c FILE *fin, *fout
#define fft_c_open fin = fopen("input.txt","r"); fout = fopen("output.txt","w")
#define fft_c_cl fclose(fin); fclose(fout)
#define pii pair<ll,ll>
#define pff pair<float,float>
#define piii pair<int,pair<int,int>>
#define M_PI 3.14159265358979323846
typedef unsigned long long ull;
typedef signed long long ll;
const int INF = 1e9;
const int MAXM = 1000000007;
const int MAX = 1e7;
const int des = 10000;

const int maxn = 3005;

int n;
bool used[maxn];
int check[maxn];
vector<int> roads[maxn];
bool road[maxn][maxn];

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

	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++) {
			road[i][j] = false;
		}

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		roads[a].push_back(b);
		road[a][b] = true;
	}

	ll ans = 0;

	for(int a = 0; a < n; a++)
	for(int b = 0; b < n; b++) {
		if(a == b)
			continue;

		ll r = 0;

		for(int i = 0; i < roads[a].size(); i++) {
			if(road[ roads[a][i] ][b] == true) {
				r++;
			}
		}

		ans += r * (r - 1) / 2LL;
	}

	cout << ans << endl;

	//pp;
}


#define _CRT_SECURE_NO_WARNINGS

#include <string>
#include <sstream>
#include <cstring>
#include <sstream>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <ctime>
#include <cmath>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <iomanip>
using namespace std;

#define pp system("pause");
#define ct double ttme = clock()
#define p_ct cout << (clock() - ttme) / CLOCKS_PER_SEC << endl
#define all(c) (c).begin(),(c).end()
#define fft ifstream fin("input.txt"); ofstream fout("output.txt")
#define fft_c FILE *fin, *fout
#define fft_c_open fin = fopen("input.txt","r"); fout = fopen("output.txt","w")
#define fft_c_cl fclose(fin); fclose(fout)
#define pii pair<ll,ll>
#define pff pair<float,float>
#define piii pair<int,pair<int,int>>
#define M_PI 3.14159265358979323846
typedef unsigned long long ull;
typedef signed long long ll;
const int INF = 1e9;
const int MAXM = 1000000007;
const int MAX = 1e7;
const int des = 10000;

const int maxn = 3005;

int n;
bool used[maxn];
int check[maxn];
vector<int> roads[maxn];

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

	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		roads[a].push_back(b);
	}

	ll ans = 0;

	for(int a = 0; a < n; a++)
	for(int b = 0; b < n; b++) {
		if(a == b)
			continue;

		ll r = 0;

		for(int i = 0; i < roads[a].size(); i++) {
			for(int z = 0; z < roads[ roads[a][i] ].size(); z++) {
				if(roads[ roads[a][i] ][z] == b) {
					r++;
				}
			}
		}

		ans += r * (r - 1) / 2LL;
	}

	cout << ans << endl;

	//pp;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = (int)3e3 + 10;
const int maxm = (int)3e4 + 10;
int n, m;
vector<int> e[maxn];
int cnt[maxn][maxn];
long long ans;

void gao(int r, int x, int p, int s) {
	if (s > 2) return;
	if (s == 2) cnt[r][x] += 1;
	for (int i = 0; i < e[x].size(); i++) {
		int c = e[x][i];
		if (c != p) {
			gao(r, c, x, s + 1);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int j, k;
		cin >> j >> k;
		e[j].push_back(k);
		//e[k].push_back(j);
	}
	for (int i = 1; i <= n; i++) {
		gao(i, i, -1, 0);
	}
	for (int i = 1; i <= n; i++) {
		//cout << i << ':' << endl;
		for (int j = 1; j <= n; j++) {
			if (cnt[i][j] >= 2) {
				ans += 1LL * cnt[i][j] * (cnt[i][j] - 1) / 2;
			}
		//	cout << cnt[i][j] << ' ';
			}
		//cout << endl;
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = (int)3e3 + 10;
const int maxm = (int)3e4 + 10;
int n, m;
vector<int> in[maxn], out[maxn];
long long ans;

int calc(vector<int> &a, vector<int> &b) {
	int ret = 0, i = 0, j = 0;
	while (i < a.size() && j < b.size()) {
		if (a[i] == b[j]) {
			ret += 1;
			i += 1;
			j += 1;
		}
		else if (a[i] < b[j]) {
			i += 1;
		}
		else {
			j += 1;
		}
	}
	return ret;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int j, k;
		cin >> j >> k;
		out[j].push_back(k);
		in[k].push_back(j);
	}
	for (int i = 1; i <= n; i++) {
		sort(in[i].begin(), in[i].end());
		sort(out[i].begin(), out[i].end());
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			if (i == j) continue;
			int tmp = calc(out[i], in[j]);
			if (tmp >= 2) {
				ans += 1LL * tmp * (tmp - 1) / 2;
			}
		}
	cout << ans << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>

#include <time.h>
#pragma comment(linker, "/STACK:20000000")

#define fr(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define fd(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

int ri(){int x;scanf("%d",&x);return x;}
ll rll(){ll x;scanf("%lld",&x);return x;}

vector<int> graph[3050];

int dp[4][3050];

void solve()
{
	int n = ri(),m = ri();
	fr(i,1,m)
	{
		int a = ri(),b = ri();
		graph[a].pb(b);
	}
	ll res = 0;
	fr(i,1,n)
	{
		queue<int> st;
		memset(dp,0,sizeof(dp));
		st.push(i);
		dp[0][i] = 1;
		int step = 0;
		while(step <= 2 && !st.empty())
		{
			step++;
			for(int j = 0,maxj = st.size();j < maxj;j++)
			{
				int v = st.front();
				st.pop();
				for(int k = 0;k < graph[v].size();k++)
				{
					int to = graph[v][k];
					if (dp[step][to] == 0)
						st.push(to);
					dp[step][to] += dp[step - 1][v];
				}
			}
		}
		ll cnt = 0;
		fr(j,1,n)
		{
			cnt = i == j ? 0 : dp[2][j];
			res += (cnt * (cnt - 1)) / 2;
		}
	}
	cout << res << endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/input.txt","rt",stdin);
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/output.txt","wt",stdout);
	#else
		//freopen("input.in","rt",stdin);
		//freopen("output.out","wt",stdout);
	#endif

	solve();

	#ifndef ONLINE_JUDGE
		printf("\n\ntime-%.3lf",clock()*1e-3);
	#endif

	return 0;
}


#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stdlib.h>
#include <sstream>
#include <assert.h>

#include <time.h>
#pragma comment(linker, "/STACK:20000000")

#define fr(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define fd(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define mp make_pair
#define pb push_back
#define ll long long

using namespace std;

int ri(){int x;scanf("%d",&x);return x;}
ll rll(){ll x;scanf("%lld",&x);return x;}

vector<int> graph[30500];

int dp[4][3050];

void solve()
{
	int n = ri(),m = ri();
	fr(i,1,m)
	{
		int a = ri(),b = ri();
		graph[a].pb(b);
	}
	ll res = 0;
	fr(i,1,n)
	{
		queue<int> st;
		memset(dp,0,sizeof(dp));
		st.push(i);
		dp[0][i] = 1;
		int step = 0;
		while(step <= 2 && !st.empty())
		{
			step++;
			for(int j = 0,maxj = st.size();j < maxj;j++)
			{
				int v = st.front();
				st.pop();
				for(int k = 0;k < graph[v].size();k++)
				{
					int to = graph[v][k];
					if (dp[step][to] == 0)
						st.push(to);
					dp[step][to] += dp[step - 1][v];
				}
			}
		}
		ll cnt = 0;
		fr(j,1,n)
			cnt += dp[2][j];
		cnt -= dp[2][i];
		res += cnt / 2;
	}
	cout << res << endl;
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/input.txt","rt",stdin);
		freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/output.txt","wt",stdout);
	#else
		//freopen("input.in","rt",stdin);
		//freopen("output.out","wt",stdout);
	#endif

	solve();

	#ifndef ONLINE_JUDGE
		printf("\n\ntime-%.3lf",clock()*1e-3);
	#endif

	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <ctime>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
#ifdef _HOME_
	ifstream cin("input.txt");
#else
	//freopen(TASK ".in", "r", stdin);
	//freopen(TASK ".out", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	vector <vector <int> > g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		g[u - 1].push_back(v - 1);
	}

	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < g[i].size(); j++) {
			vector <bool> u(n);
			int to1 = g[i][j];
			for (int k = 0; k < g[to1].size(); k++)
				u[g[to1][k]] = true;

			for (int k = j + 1; k < g[i].size(); k++) {
				for (int l = 0; l < g[g[i][k]].size(); l++)
					if (u[g[g[i][k]][l]] && g[g[i][k]][l] != i)
						ans++;
			}
		}

	cout << ans << endl;

#ifdef _HOME_
	system("pause");
#endif
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <ctime>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
#ifdef _HOME_
	ifstream cin("input.txt");
#else
	//freopen(TASK ".in", "r", stdin);
	//freopen(TASK ".out", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	vector <vector <int> > g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		g[u - 1].push_back(v - 1);
	}

	int ans = 0;
	vector <bool> u(n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < g[i].size(); j++) {
			int to1 = g[i][j];
			for (int k = 0; k < g[to1].size(); k++)
				u[g[to1][k]] = true;

			for (int k = j + 1; k < g[i].size(); k++) {
				for (int l = 0; l < g[g[i][k]].size(); l++)
					if (u[g[g[i][k]][l]]) {
						ans++;
						break;
					}
			}
			u.assign(n, false);
		}

	cout << ans << endl;

#ifdef _HOME_
	system("pause");
#endif
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <ctime>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
#ifdef _HOME_
	ifstream cin("input.txt");
#else
	//freopen(TASK ".in", "r", stdin);
	//freopen(TASK ".out", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	vector <vector <int> > g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		g[u - 1].push_back(v - 1);
	}

	int ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < g[i].size(); j++) {
			vector <bool> u(n);
			int to1 = g[i][j];
			for (int k = 0; k < g[to1].size(); k++)
				u[g[to1][k]] = true;

			for (int k = j + 1; k < g[i].size(); k++) {
				for (int l = 0; l < g[g[i][k]].size(); l++)
					if (u[g[g[i][k]][l]])
						ans++;
			}
		}

	cout << ans << endl;

#ifdef _HOME_
	system("pause");
#endif
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <ctime>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
#ifdef _HOME_
	ifstream cin("input.txt");
#else
	//freopen(TASK ".in", "r", stdin);
	//freopen(TASK ".out", "w", stdout);
#endif

	int n, m;
	cin >> n >> m;

	vector <vector <int> > g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		g[u - 1].push_back(v - 1);
	}

	vector <vector <int> > k2(n);
	for (int i = 0; i < n; i++)
		k2[i].resize(n);

	vector <int> q;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < g[i].size(); j++)
			q.push_back(g[i][j]);

		while (q.size() > 0) {
			int v = q[q.size() - 1];
			q.pop_back();
			for (int j = 0; j < g[v].size(); j++)
				if (g[v][j] != i)
					k2[i][g[v][j]]++;
		}
	}

	ll ans = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (k2[i][j] > 1)
				ans += (k2[i][j]*(k2[i][j] - 1))/2;

	cout << ans << endl;

#ifdef _HOME_
	system("pause");
#endif
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <stack>
#include <set>
#include <algorithm>
#include <list>
#pragma comment(linker, "/STACK:167772160")
using namespace std;
//8739
const double PI = 3.14159265358979323846;
const long long MODUL = 1000000007;
const long long MAXINT = 2e9 + 2;
const long long MAXLL = 2e18 + 2;
const double eps = 1e-8;
const int MAXN = 3e3 + 10;

int n, m, a ,b;
long long ans(0), cnt[MAXN];
vector<int> mas[MAXN];

void init()
{
    cin >> n >> m;
    for(int i(0); i < m; ++i)
        cin >> a >> b, mas[a].push_back(b);
}

void solve()
{
    for(int i(1); i <= n; ++i)
    {
        for(int j(1); j <= n; ++j)
            cnt[j] = 0;
        for(int j(0); j < mas[i].size(); ++j)
            for(int k(0); k < mas[mas[i][j]].size(); ++k)
                ++cnt[mas[mas[i][j]][k]];
        for(int j(1); j <= n; ++j)
            ans += cnt[j] * (cnt[j] - 1) / 2;
        ans -= cnt[i] * (cnt[i] - 1) / 2;
    }
}

void output()
{
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    init();
    solve();
    output();
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int n;
vector<vector<int> > grid;
int f[3000][3000];

void init()
{
	grid.resize(n, vector<int>(n,0));
}

void initF()
{
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			f[i][j]=0;
		}
	}
}

long long get()
{
	for (int i = 0; i < n ;i++){
		for (int j = 0; j < grid[i].size(); j++){
			if (i!=j && grid[i][j]==1){
				for (int k = 0; k< grid[j].size(); k++){
					if (j!=k && k!=i && grid[j][k] == 1){
						f[i][k]+=1;
					}
				}
			}
		}
	}
	long long total = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (i!=j && f[i][j]!=0 ){
				total+= (f[i][j] * (f[i][j]-1))/2;
			}
		}
	}
	return total;
}

int main()
{
	int m;
	cin >> n >> m;
	init();
	initF();
	for (int i = 0; i<m; i++){
		int a,b;
		cin >> a >> b;
		a-=1;
		b-=1;
		grid[a][b]=1;
	}
	cout << get() << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <stack>
#include <cstdio>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <fstream>
#include <list>
#include <map>
#include <string>
#include <cstdlib>
#include <functional>
#include <bitset>
#include <iomanip>
#include <ctime>
using namespace std;
#pragma comment(linker,"/STACK:17000000")
const double eps = 1e-9; const double inf = 1e+9;
typedef long long ll;
typedef pair<int, int> P;
typedef double db;

int n, m;
vector<vector<int> >g;
vector<int> c;
int main(){
    scanf("%d%d", &n, &m);
    g.resize(n);
    c.resize(n);
    for (int i = 0,t1,t2; i < m; i++){
        scanf("%d%d", &t1, &t2); t1--; t2--;
        g[t1].push_back(t2);
    }
    ll ans = 0;

    for (int i = 0; i < n; i++){
        c.assign(n, 0);
        for (int j = 0; j < g[i].size(); j++){
            int v = g[i][j];
            for (int k = 0; k < g[v].size(); k++){
                c[g[v][k]]++;
            }
        }
        for (int j = 0; j < n; j++){
            if(j!=i)ans += (c[j] * (c[j] - 1)) / 2;
        }
    }
    cout << ans;
}
/*
5 4
1 2
2 3
1 4
4 3

*/


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <stack>
#include <cstdio>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <fstream>
#include <list>
#include <map>
#include <string>
#include <cstdlib>
#include <functional>
#include <bitset>
#include <iomanip>
#include <ctime>
using namespace std;
#pragma comment(linker,"/STACK:17000000")
const double eps = 1e-9; const double inf = 1e+9;
typedef long long ll;
typedef pair<int, int> P;
typedef double db;

int n, m;
vector<set<int> >g;
int main(){
    scanf("%d%d", &n, &m);
    g.resize(n);
    for (int i = 0,t1,t2; i < m; i++){
        scanf("%d%d", &t1, &t2); t1--; t2--;
        g[t1].insert(t2);
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            if (i == j)continue;
            int k = 0;
            for (set<int>::iterator it = g[i].begin(); it != g[i].end(); it++){
                if (g[(*it)].count(j))k++;
            }
            ans += (k*(k - 1)) / 2;
        }
    }
    cout << ans;
}
/*
5 4
1 2
2 3
1 4
4 3

*/


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <ctime>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <cmath>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
const ll size = 3007;
const ll modulo = 1000000007;
const int oo = 1e9;
const double EPS = 1e-12;
const double PI = 3.14159;

vector<int> in[3007], out[3007];
short matr[3007][3007], incom[3007][3007];
short outcom[3007][3007], sub[3007][3007];

int main()
{
	int n,m;
	cin >> n >> m;
	while (m--)
	{
		int a, b;
		cin >> a >> b;
		in[b].push_back(a);
		out[a].push_back(b);
		matr[a][b] = 1;
	}
	for (int v = 1; v <= n; v++)
	{
		int len = in[v].size();
		for (int i = 0; i < len; i++)
		for (int j = i + 1; j < len; j++)
		{
			int v1 = in[v][i], v2 = in[v][j];
			if (v1 > v2) swap(v1, v2);
			outcom[v1][v2]++;
		}
	}
	for (int v = 1; v <= n; v++)
	{
		int len = out[v].size();
		for (int i = 0; i < len; i++)
		for (int j = i + 1; j < len; j++)
		{
			int v1 = out[v][i], v2 = out[v][j];
			if (v1 > v2) swap(v1, v2);
			incom[v1][v2]++;
			if (matr[v1][v] && matr[v2][v])
				++sub[v1][v2];
		}
	}
	ll ans = 0;
	for (int i = 1; i < n; i++)
	for (int j = i + 1; j <= n; j++)
	{
		ans += int(incom[i][j]) * outcom[i][j] - sub[i][j];
	}
	cout << ans << endl;
	return 0;
}


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

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359
#define eps  1e-9

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int n , m ;
vector<int>a[3001] ;
int dp[3001][3001] ;
bool done[5000] ;
set<pair<int , int>>vis[3001] ;
void dfs(int root , int par , int grandPar ,  int depth){

    vis[root].insert(pa(par , grandPar)) ;
    done[root] = 1 ;
    if(depth >= 2){
        dp[root][grandPar]++ ;
    }

    for(int i = 0 ; i < a[root].size() ; i++){
        if(vis[a[root][i]].count(pa(root , par)) == 0 && a[root][i] != par && a[root][i] != grandPar){
            dfs(a[root][i] , root , par ,  depth + 1);
        }
    }

    return ;
}
int main()
{
    boostIO() ;

    cin >> n >> m ;

    for(int i = 0 ; i < m ; i++){
        int u , v ; cin >> u >> v ;
        a[u].pb(v) ;
    }

    for(int i = 1 ; i <= n ; i++){
        if(!done[i]){
            dfs(i , 0 , 0 , 0) ;
        }
    }

    LL ans = 0 ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(i == j)
                continue ;
            ans = ans + (dp[i][j] * (dp[i][j] - 1)) / 2 ;
        }
    }

    cout << ans << endl  ;
}


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

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359
#define eps  1e-9

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int n , m ;
vector<int>a[3001] ;
int dp[3001][3001] ;
set<pair<int , int>>vis[3001] ;
void dfs(int root , int par , int grandPar ,  int depth){
    //cout << root << " " << par << endl ;
    vis[root].insert(pa(par , grandPar)) ;
    if(depth >= 2){
        dp[root][grandPar]++ ;
        //cout << root << " " << grandPar << endl ;
    }
    for(int i = 0 ; i < a[root].size() ; i++){
        if(vis[a[root][i]].count(pa(root , par)) == 0 && a[root][i] != par && a[root][i] != grandPar){
            dfs(a[root][i] , root , par ,  depth + 1); // this is wrong
        }
    }

    return ;
}
int main()
{
    boostIO() ;
    cin >> n >> m ;

    for(int i = 0 ; i < m ; i++){
        int u , v ; cin >> u >> v ;
        a[u].pb(v) ;
    }

    for(int i = 1 ; i <= n ; i++){
        if(vis[i].count(pa(0 , 0)) == 0){
            dfs(i , 0 , 0 , 0) ;
        }
    }

    LL ans = 0 ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(i == j)
                continue ;
            ans = ans + (dp[i][j] * (dp[i][j] - 1)) / 2 ;
        }
    }

    cout << ans << endl  ;
}


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

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359
#define eps  1e-9

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int n , m ;
vector<int>a[5000] ;
int dp[4000][4000] ;
map<int , bool> vis[3001][3001] ;
void dfs(int root , int par , int grandPar ,  int depth){
    //cout << root << " " << par << endl ;
    vis[root][par][grandPar] = 1 ;
    if(depth >= 2){
        dp[root][grandPar]++ ;
        //cout << root << " " << grandPar << endl ;
    }
    for(int i = 0 ; i < a[root].size() ; i++){
        if(vis[a[root][i]][root].count(par) == 0){
            dfs(a[root][i] , root , par ,  depth + 1); // this is wrong
        }
    }

    return ;
}
int main()
{
    boostIO() ;
    cin >> n >> m ;

    for(int i = 0 ; i < m ; i++){
        int u , v ; cin >> u >> v ;
        a[u].pb(v) ;
    }

    for(int i = 1 ; i <= n ; i++){
        if(!vis[i][0][0]){
            dfs(i , 0 , 0 , 0) ;
        }
    }

    LL ans = 0 ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(i == j)
                continue ;
            ans = ans + (dp[i][j] * (dp[i][j] - 1)) / 2 ;
        }
    }

    cout << ans << endl  ;
}


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

#define mod 1000000007
#define mod2 30000000
#define pa(a,b) make_pair(a,b)
#define f first
#define s second
#define pb(a)  push_back(a)
#define all(a) a.begin() , a.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define LL  long long int
#define oo 1e9
#define pi 3.14159265359
#define eps  1e-9

LL maxx(LL a , LL b){ return a>b ?  a : b ;}
LL minn(LL a , LL b){ return a>b ?  b : a ;}

using namespace std;
int dx[] = {1 , 1 ,1 , 0 , 0  , -1 , -1  , -1  , 0 };
int dy[] = { -1 , 0  , 1 , 1 , -1 , 0 , 1 , -1 , 0 };
void boostIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
LL gcd(LL a, LL b) {
    return b == 0 ? a : gcd(b, a % b);
}
LL lcm(LL a , LL b )
{
    return (a*b)/gcd(a , b);
}
LL poww(LL base, LL exp){
  base %= mod;
  LL result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % mod;
    base = (base * base) % mod;
    exp >>= 1;
  }
  return result;
}
int n , m ;
vector<int>a[3001] ;
int dp[3001][3001] ;
bool done[5000] ;
set<int>vis[3001] ;
void dfs(int root , int par , int grandPar ,  int depth){

    done[root] = 1 ;

    if(depth >= 2){
        dp[root][grandPar]++ ;
        vis[root].insert(grandPar) ;
    }
    cout << root << " "  << par << " " << grandPar << endl ;
    for(int i = 0 ; i < a[root].size() ; i++){
        if(vis[a[root][i]].find(par) == vis[a[root][i]].end() && a[root][i] != par && a[root][i] != grandPar){
            dfs(a[root][i] , root , par ,  depth + 1);
        }
    }

    return ;
}
int main()
{
    boostIO() ;

    cin >> n >> m ;

    for(int i = 0 ; i < m ; i++){
        int u , v ; cin >> u >> v ;
        a[u].pb(v) ;
    }
    LL ans = 0 ;

    for(int i = 1 ; i <= n ; i++){
        int cur[3005] = {0} ;

        for(int j = 0 ; j < a[i].size() ; j++){
            int x = a[i][j] ;

            for(int k = 0 ; k < a[x].size() ; k++){
                cur[a[x][k]]++ ;
            }
        }

        for(int j = 1 ; j <= n ; j++){
            if(j == i)
                continue ;
            ans = ans + (cur[j] * (cur[j] - 1)) / 2 ;
        }
    }
    /*for(int i = 1 ; i <= n ; i++){
        if(!done[i]){
            dfs(i , 0 , 0 , 0) ;
        }
    }

    LL ans = 0 ;

    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= n ; j++){
            if(i == j)
                continue ;
            ans = ans + (dp[i][j] * (dp[i][j] - 1)) / 2 ;
        }
    }*/

    cout << ans << endl  ;
}


/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<algorithm>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vc           vector
#define   vi           vc<int>
#define   vl           vc<ll>
#define   vs(v)        vector<string>v
#define   rsrt(v)      sort(v.rbegin(),v.rend());
#define   all(v)       v.begin(),v.end()
#define   pf(x)        cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   ms(x,n)      memset(x,n,sizeof(x));
#define   srt(v)       sort(v.begin(),v.end());
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n,a,b,c,d;
    tst
    {
        cin>>a>>b>>c>>d;
        if(b<=c)
            cout<<a+b<<endl;
        else cout<<a+c<<endl;
    }

    bair_ho
}


/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<algorithm>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vc           vector
#define   vi           vc<int>
#define   vl           vc<ll>
#define   vs(v)        vector<string>v
#define   rsrt(v)      sort(v.rbegin(),v.rend());
#define   all(v)       v.begin(),v.end()
#define   pf(x)        cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   ms(x,n)      memset(x,n,sizeof(x));
#define   srt(v)       sort(v.begin(),v.end());
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n,a,b,c,d;
    tst
    {
        cin>>a>>b>>c>>d;
        if((a+1)+c<=(a+b))
            cout<<(a+1)+c<<endl;
        else cout<<(a+b)<<endl;
    }

    bair_ho
}


/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<algorithm>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vc           vector
#define   vi           vc<int>
#define   vl           vc<ll>
#define   vs(v)        vector<string>v
#define   rsrt(v)      sort(v.rbegin(),v.rend());
#define   all(v)       v.begin(),v.end()
#define   pf(x)        cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   ms(x,n)      memset(x,n,sizeof(x));
#define   srt(v)       sort(v.begin(),v.end());
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n,a,b,c,d;
    tst
    {
        cin>>a>>b>>c>>d;
       ll x,y;
      cout<<(b-a)+b<<endl;
    }

    bair_ho
}


/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<algorithm>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vc           vector
#define   vi           vc<int>
#define   vl           vc<ll>
#define   vs(v)        vector<string>v
#define   rsrt(v)      sort(v.rbegin(),v.rend());
#define   all(v)       v.begin(),v.end()
#define   pf(x)        cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   ms(x,n)      memset(x,n,sizeof(x));
#define   srt(v)       sort(v.begin(),v.end());
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n,a,b,c,d;
    tst
    {
        cin>>a>>b>>c>>d;
       ll x,y;
       x = max(a,d);
       y = min(b,c);
       cout<<x+y<<endl;
    }

    bair_ho
}


/*Starting with the name of Almighty ALLAH*/
/* Bismillahir Rahmanir Rahim */
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<string>
#include<stdlib.h>
#include<algorithm>
#define   ebar_khela_hoppe int main()
#define   bair_ho      return 0;
#define   mod          1000000007
#define   lp(i,a,b)    for(ll i=a;i<=b;i++)
#define   ll           long long int
#define   ull          unsigned long long int
#define   tst          int t;cin>>t;while(t--)
#define   pb           push_back
#define   vc           vector
#define   vi           vc<int>
#define   vl           vc<ll>
#define   vs(v)        vector<string>v
#define   rsrt(v)      sort(v.rbegin(),v.rend());
#define   all(v)       v.begin(),v.end()
#define   pf(x)        cout<<x<<endl;
#define   mp(x,y)      make_pair(x,y)
#define   yes          cout<<"YES"<<endl;
#define   no           cout<<"NO"<<endl;
#define   ms(x,n)      memset(x,n,sizeof(x));
#define   srt(v)       sort(v.begin(),v.end());
#define   rvs(v)       reverse(v.begin(),v.end());
#define   Araf         ios::sync_with_stdio(false);cin.tie(0);
#define   gcd(a,b)     __gcd(a,b)
#define   lcm(a,b)     (a/gcd(a,b))*b
#define   str          int s[200000];
#define   coutv(v)     for(auto it:v)cout<<it<<' ';cout<<endl;
#define   cinv(v)      for(auto &it:v)cin>>it;
using namespace std;
ebar_khela_hoppe
{
    Araf
    ll n,a,b,c,d;
    tst
    {
        cin>>a>>b>>c>>d;
        cout<<a+b<<endl;
    }

    bair_ho
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a[100000],c[100000];
pair<int,int> p[100000];
int main()
{
    int n,i,j,k,t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        vector<int> v;
        v.push_back(a+b);
        v.push_back(c+d);
        sort(v.begin(),v.end());
        cout<<v[1]<<endl;
    }
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a[100000],c[100000];
pair<int,int> p[100000];
int main()
{
    int n,i,j,k,t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        vector<int> v;
        v.push_back(a+b);
        v.push_back(c+d);
        sort(v.begin(),v.end());
        cout<<v[0]<<endl;
    }
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a[100000],c[100000];
pair<int,int> p[100000];
int main()
{
    int n,i,j,k,t;
    scanf("%d",&t);
    while(t--)
    {
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        vector<int> v;
        v.push_back(a+b);
        v.push_back(c+d);
        v.push_back(a+c);
        sort(v.begin(),v.end());
        cout<<v[1]<<endl;
    }
}


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

int main (){
	int n ;
	cin >> n ;
	while(n--){
		int a , b , c , d , ans ;
		cin >> a >> b >> c >> d ;
		ans = max(a+b , c + d );
		cout << ans << endl;
	}
}


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

int main (){
	int n ;
	cin >> n ;
	while(n--){
		int a , b , c , d , ans ;
		cin >> a >> b >> c >> d ;
		if((a + b) > (c + d)){
			ans = a + b ;
		}else if( c + d > a + b){
			ans = c + d ;
		}
		else
		{
			ans = a + b ;
		}
		cout << ans << endl;
	}
}


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

#define endl     "\n"
#define ll       long long
#define PI       acos(-1.0)
#define test     cout<<"\n****\n"
#define LCM(a,b) ((a/__gcd(a,b))*b)
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define precise  fixed(cout);cout<<setprecision(20)
#define fast     ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int>a,b;

int main(){

    fast;
    int t;
    cin>>t;

    while(t--){

        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<a+b<<endl;
    }
    return 0;
}


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

#define endl     "\n"
#define ll       long long
#define PI       acos(-1.0)
#define test     cout<<"\n****\n"
#define LCM(a,b) ((a/__gcd(a,b))*b)
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define precise  fixed(cout);cout<<setprecision(20)
#define fast     ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int>a,b;

int main(){

    fast;
    int t;
    cin>>t;

    while(t--){

        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<a+c<<endl;
    }
    return 0;
}


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

#define endl     "\n"
#define ll       long long
#define PI       acos(-1.0)
#define test     cout<<"\n****\n"
#define LCM(a,b) ((a/__gcd(a,b))*b)
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define precise  fixed(cout);cout<<setprecision(20)
#define fast     ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

vector<int>a,b;

int main(){

    fast;
    int t;
    cin>>t;

    while(t--){

        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a+b,c+d)<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a == d)
		cout<<a+c<<endl;
		else
		cout<<a+b<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a == d)
		cout<<a+c<<endl;
		if(a!=d&&b!=c)
		{
			int minn = a+b;
			for(int i=d;i<=a;i++)
			{
				if(c+i>=minn)
				{
					cout<<c+i<<endl;
					break;
				}
			}
		}
		if(a!=d&&b==c)
		cout<<a+c<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a == d&&c>b)
		cout<<a+c<<endl;
		if(a == d&&c == b)
		cout<<a+b<<endl;
		if(a!=d&&b!=c)
		{
			int minn;
			minn = min(a+b,a+c);
			cout<<minn<<endl;
		}
		if(a!=d&&b==c)
		cout<<a+c<<endl;
	}
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stack>
#include<set>
#include<string>
#include<map>
#include<cmath>
#include<stdlib.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e3+5;
using namespace std;
int t,a,b,c,d;
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>a>>b>>c>>d;
        cout<<max(a+b,c+d)<<endl;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stack>
#include<set>
#include<string>
#include<map>
#include<cmath>
#include<stdlib.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e3+5;
using namespace std;
int t,a,b,c,d;
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>a>>b>>c>>d;
        if(a<b&&a+c<=b+d)
            cout<<a+c<<endl;
        else
            cout<<a+b<<endl;
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#define fo(x,a,b) for(int x=(a),e_=(b);x<=e_;x++)
#define fd(x,a,b) for(int x=(a),e_=(b);x>=e_;x--)
#define pb push_back
#define ww printf
#define mp make_pair
#define clr(A) memset(A,0,sizeof(A))

using namespace std;
typedef long long ll;
int zm,a,b,c,d;
int main(){
	scanf("%d",&zm);
	while(zm--){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(b==c || a==d) printf("%d\n",a+c);
		else printf("%d\n",max(a+b,c+d));
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<algorithm>
#define fo(x,a,b) for(int x=(a),e_=(b);x<=e_;x++)
#define fd(x,a,b) for(int x=(a),e_=(b);x>=e_;x--)
#define pb push_back
#define ww printf
#define mp make_pair
#define clr(A) memset(A,0,sizeof(A))

using namespace std;
typedef long long ll;
int zm,a,b,c,d;
int main(){
	scanf("%d",&zm);
	while(zm--){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		if(b==c) printf("%d\n",a+c);
		else if(a==d) printf("%d\n",b+d);
		else printf("%d\n",max(a+b,c+d));
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<min(max(a+c,b+d),max(a+b,c+d))<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<(a+b+c+d+1)/2<<'\n';
    }
    return 0;
}


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

const int maxn=1e3+2;

//int a[maxn],b[maxn];

bool cmp(int x,int y)
{
	return x>y;
}

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

	if( a<=d or b>=c ) printf("%d\n",min(a+b,c+d));
	else printf("%d\n",max(a+b,c+d));

	return;
}

int main()
{
	int kase;scanf("%d",&kase);
	while(kase--) solve();

	return 0;
}


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

const int maxn=1e3+2;

//int a[maxn],b[maxn];

bool cmp(int x,int y)
{
	return x>y;
}

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

	printf("%d\n",max(b+a,c+d));

	return;
}

int main()
{
	int kase;scanf("%d",&kase);
	while(kase--) solve();

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
    //fstream file("data.txt");
    int t;
    int a,b,c,d;
    cin>>t;
    for (int i = 0; i < t; i++){
        cin>>a>>b>>c>>d;
        if(a+b > c+d) cout<<(a+b)<<endl;
        else cout<< (c+d)<<endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b > c+d) cout<<(a+b);
    else cout<< (c+d);
    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
    int t;
    int a,b,c,d;
    cin>>t;
    for (int i = 0; i < t; i++)
    {
        cin>>a>>b>>c>>d;
        if(a+b > c+d) cout<<(a+b);
        else cout<< (c+d);
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int _;
	for(cin>>_;_;_--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<min({c+d+1,a+b+1,a+c})<<endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int _;
	for(cin>>_;_;_--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<min(max(a+b,c+d),a+c)<<endl;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
	int _;
	for(cin>>_;_;_--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		cout<<min(c+d+1,a+b+1,a+c)<<endl;
	}
	return 0;
}


//https://codeforces.com/problemset/problem/1445/B

#include <bits/stdc++.h>

using namespace std;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << max (a+b, c+d) << endl;
    }
    return 0;
}


//https://codeforces.com/problemset/problem/1445/B

#include <bits/stdc++.h>

using namespace std;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << max (a,d) + min (b,c) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

#define ll              long long int
#define ull             unsigned long long int
#define vl              vector<ll>
#define all(v)          v.begin(),v.end()
#define pb              push_back
#define pf              printf
#define scln(x)         scanf("%lld",&(x))
#define pll             pair < ll, ll>
#define MP              make_pair
#define gcd(a,b)        __gcd(a , b)
#define lcm(a,b)        (a*(b/__gcd(a,b)))
#define mSet(a,b)       memset(a,b,sizeof(a))
#define MOD             1000000007
#define PI              2*acos(0.0)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll tc = 1;
    cin >> tc;

    while(tc--)
    {

        ll n, a, b,c,d;

        cin >> a >> b >> c >> d;

        ll m1 = max(a , d);
        ll m2 = min(b, c);

        cout << (m1+m2) << endl;

    }
    return 0;
}


#include<bits/stdc++.h>

#define ll              long long int
#define ull             unsigned long long int
#define vl              vector<ll>
#define all(v)          v.begin(),v.end()
#define pb              push_back
#define pf              printf
#define scln(x)         scanf("%lld",&(x))
#define pll             pair < ll, ll>
#define MP              make_pair
#define gcd(a,b)        __gcd(a , b)
#define lcm(a,b)        (a*(b/__gcd(a,b)))
#define mSet(a,b)       memset(a,b,sizeof(a))
#define MOD             1000000007
#define PI              2*acos(0.0)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll tc = 1;
    cin >> tc;

    while(tc--)
    {

        ll n, a, b,c,d;

        cin >> a >> b >> c >> d;

        ll m1 = a;
        ll m2 = min(b, c);

        cout << (m1+m2) << endl;

    }
    return 0;
}


#include<bits/stdc++.h>

#define ll              long long int
#define ull             unsigned long long int
#define vl              vector<ll>
#define all(v)          v.begin(),v.end()
#define pb              push_back
#define pf              printf
#define scln(x)         scanf("%lld",&(x))
#define pll             pair < ll, ll>
#define MP              make_pair
#define gcd(a,b)        __gcd(a , b)
#define lcm(a,b)        (a*(b/__gcd(a,b)))
#define mSet(a,b)       memset(a,b,sizeof(a))
#define MOD             1000000007
#define PI              2*acos(0.0)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll tc = 1;
    cin >> tc;

    while(tc--)
    {

        ll n, a, b,c,d;

        cin >> a >> b >> c >> d;

        ll m1 = max(a + b , max(b+d , c+d));
        //ll m2 = min(b, c);

        cout << (m1) << endl;

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
inline void read(int &num)
{
	num = 0;
	int f=1;
	char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		num=num*10+c-48;
		c=getchar();
	}
	num*=f;
}
int t,a,b,c,d;
signed main()
{
	read(t);
	while(t--)
	{
		read(a),read(b),read(c),read(d);
		cout<<max(a+b,c+d)<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (c == b)
            cout << a + b;
        else if (a == d)
            cout << c + d;
        else
            cout << (((a + b) > (c + d)) ? (a + b) : (c + d)) << '\n';
    }
}


#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (c == b)
            cout << a + b << '\n';
        else if (a == d)
            cout << c + d << '\n';
        else
            cout << (((a + b) > (c + d)) ? (a + b) : (c + d)) << '\n';
    }
}


#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if (c == b)
            cout << a + b;
        else if (a == d)
            cout << c + d;
        else
            cout << (((a + b) > (c + d)) ? (a + b) : (c + d));
    }
}


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

int a,b,c,d,t;

int main()
{
  scanf("%d",&t);
  while(t!=0){
    t--;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    cout<<max(a+b,c+d)<<endl;
  }
}


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

int a,b,c,d,t;

int main()
{
  scanf("%d",&t);
  while(t!=0){
    t--;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    cout<<min(a+b,c+d)<<endl;
  }
}


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

int a,b,c,d,t;

int main()
{
  scanf("%d",&t);
  while(t!=0){
    t--;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    cout<<min(a+b,c+d);
  }
}


///..............*****.................///
///   Saiful Alam                      ///
///   Department of CSE                ///
///   Comilla University , Bangladesh. ///
///..............****..................///
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair <ll,ll>
#define  pq         priority_queue
#define  pb         push_back
#define  mpa         make_pair
#define  yes        pf("YES\n")
#define  no         pf("NO\n")
#define all(v)      v.begin(), v.end()
#define unq(v)      v.erase(unique(all(v)),v.end());
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	ll ca;
	cin>>ca;
	while(ca--){
	ll n,i,j,k;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<ll>v1,v2;
    v1.pb(a+1);
    v2.pb(c);
    v1.pb(a);
    v2.pb(c+1);
    v1.pb(a);
    v2.pb(b);
    v1.pb(c);
    v2.pb(d);
    ll mi=1e15;
    ll aa,bb;
    for(i=0;i<v1.size();i++){
        ll x=v1[i],y=v2[i];
       // cout<<x<<" "<<y<<endl;
        ll z=max(x,y);
        if(mi>=z){
            mi=z;
            aa=x;
            bb=y;
        }

    }
    cout<<aa+bb<<endl;
}

	return 0;
}
//https://github.com/me-shaon/bangla-programming-resources
//Dxz3rhdh41
//Mirth
//Realignment2@2@
//Realignment45563
//dxz3rhdh@41


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a+b,c+d)<<endl;
    return 0;
}


///..............*****.................///
///   Saiful Alam                      ///
///   Department of CSE                ///
///   Comilla University , Bangladesh. ///
///..............****..................///
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair <ll,ll>
#define  pq         priority_queue
#define  pb         push_back
#define  mpa         make_pair
#define  yes        pf("YES\n")
#define  no         pf("NO\n")
#define all(v)      v.begin(), v.end()
#define unq(v)      v.erase(unique(all(v)),v.end());
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	ll ca;
	cin>>ca;
	while(ca--){
	ll n,i,j,k;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<a+b<<endl;
}

	return 0;
}
//https://github.com/me-shaon/bangla-programming-resources
//Dxz3rhdh41
//Mirth
//Realignment2@2@
//Realignment45563
//dxz3rhdh@41


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ca;
    cin>>ca;
    while(ca--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<max(a+b,c+d)<<endl;
    }
    return 0;
}


///..............*****.................///
///   Saiful Alam                      ///
///   Department of CSE                ///
///   Comilla University , Bangladesh. ///
///..............****..................///
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair <ll,ll>
#define  pq         priority_queue
#define  pb         push_back
#define  mpa         make_pair
#define  yes        pf("YES\n")
#define  no         pf("NO\n")
#define all(v)      v.begin(), v.end()
#define unq(v)      v.erase(unique(all(v)),v.end());
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	ll ca;
	cin>>ca;
	while(ca--){
	ll n,i,j,k;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>b) swap(a,b);
    if(c>d) swap(c,d);
    if(b<d){
        cout<<a+b<<endl;
    }
    else if(b==d){
        if(a<b) cout<<a+b<<endl;
        else cout<<c+d<<endl;
    }
    else cout<<c+d<<endl;
}

	return 0;
}
//https://github.com/me-shaon/bangla-programming-resources
//Dxz3rhdh41
//Mirth
//Realignment2@2@
//Realignment45563
//dxz3rhdh@41


///..............*****.................///
///   Saiful Alam                      ///
///   Department of CSE                ///
///   Comilla University , Bangladesh. ///
///..............****..................///
#include<bits/stdc++.h>
#define  p5         100005
#define  p6         1000007
#define  PI         acos(-1)
#define  M          1000000007
#define  sc         scanf
#define  ss         second
#define  ff         first
#define  pf         printf
#define  scin(x)    sc("%d",&x)
#define  scin2(x,y) sc("%d%d",&x,&y)
#define  READ(f)    freopen(f, "r", stdin)
#define  WRITE(f)   freopen(f, "w", stdout)
#define  ll         long long
#define  pp         pair <ll,ll>
#define  pq         priority_queue
#define  pb         push_back
#define  mpa         make_pair
#define  yes        pf("YES\n")
#define  no         pf("NO\n")
#define all(v)      v.begin(), v.end()
#define unq(v)      v.erase(unique(all(v)),v.end());
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	ll ca;
	cin>>ca;
	while(ca--){
	ll n,i,j,k;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a==d && b==c){
        cout<<a+c<<endl;
        continue;
    }
    vector<ll>v1,v2;
    v1.pb(a+1);
    v2.pb(c);
    v1.pb(a);
    v2.pb(c+1);
    v1.pb(a);
    v2.pb(b);
    v1.pb(c);
    v2.pb(d);
    ll mi=1e15;
    ll aa,bb;
    for(i=0;i<v1.size();i++){
        ll x=v1[i],y=v2[i];
        ll z=max(x,y);
        if(mi>z){
            mi=z;
            aa=x;
            bb=y;
        }

    }
    cout<<aa+bb<<endl;
}

	return 0;
}
//https://github.com/me-shaon/bangla-programming-resources
//Dxz3rhdh41
//Mirth
//Realignment2@2@
//Realignment45563
//dxz3rhdh@41


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left vadia
#define right puta
using namespace std;
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9+7;
const int MAXN = 5005;
const int MAXV = 1e6+5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a+b, c+d) << endl;
}

int32_t main() {
    int ct;
    cin >> ct;
    while(ct--)
        solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <chrono>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define fin cin
#define fout cout
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
#define all(x) x.begin(), x.end()
#define left vadia
#define right puta
using namespace std;
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
typedef pair<ll, ll> pii;
typedef vector<vector<char>> mat;
typedef pair<int, string> pis;
const ll mod = 1e9+7;
const int MAXN = 5005;
const int MAXV = 1e6+5;
typedef vector<int> vi;
typedef pair<int, pair<int, int>> piii;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a+b, c+d) << endl;
}

int32_t main() {
    int ct;
    cin >> ct;
    while(ct--)
        solve();
}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        x=a+b;
        x/=2;
        y=c+d;
        y/=2;
        ans=x+y+1;
        cout<<ans<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        cout<<a+b<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        n=a+d;
        m=b+c;
        x=n+m;
        if(x%2)
        {
            ans=x/2;
            ans++;
        }
        else
        {
            ans=x/2;
        }
        cout<<ans<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        cout<<a+c<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        if(b==c)
        {
            ans=a+b;
        }
        else{
            ans=a+c;
            ans--;
        }
        cout<<ans<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define mem(x,r) memset(x,r,sizeof(x))
#define inf 1000000000000
using namespace std;
using ll=long long;
const int N=1e1+4;

//////graph////////

vector<int>circle;
bool vis[N];
int parent[N];
ll chk[N];
int color[N];
int tim[N];
int dis[N];
int position[N];
vector<int>adj[N];
vector<int>adj1[N];
vector<int>graph[N];
bool has_cycle;
int maxdis,maxnode,Totnode,depth=1;
bool ok;
queue<int>q;
stack<int>stk;
vector<int>solution;
int indegree[N];
int go[N];
int to[N];
ll x1,x2,x3,x4,x5,x6;
string ss;
int gn,gk;

//////graph////////

int main()
{

    Read_Fast;
    int t=1;
    cin>>t;
    int cas=0;
    while(t--)
    {
        ll n,m,i,j,cnt=0,cnt1=0,cnt2=0,even=0,odd=0,len,k,r,l,z=0,x=0,y=0,flag=0,sum=0;
        ll a=0,b=0,c=0,d=0,ans=0,rem,quot,zero=0,fst=0,null=0,snd=0,lst=0,rone=0,one=0,pos=0,neg=0,mn=INT_MAX,mx=INT_MIN;

        char ch;

        ////Time/////
        int h1,h2,m1,m2,h;

        ////motion ////
        int velo1,velo2,ac1,ac2,tim,hour,mint,sec;

        /////Graph///
        int node,edge,u,v,cost;
        int bst,wrst;
        double nd,ad,bd,xd=0.00,sumd=0.00;
        string str,str1="",str2="",str3="",strstore1="",strstore2="";

        //////Input Node //////

        cin>>a>>b>>c>>d;

        n=a+b;
        m=c+d;

        if(n%2)
        {
            x=n/2;
            x++;
            flag=1;
        }
        else
        {
            x=n/2;
        }

        if(m%2)
        {
            y=m/2;
            if(flag==0)
            {
                y++;
            }
        }
        else
        {
            y=n/2;
        }

        cout<<x+y<<endl;

    }
    return 0;
//////***###            ٱلْحَمْدُ لِلَّٰهِ          ###***//////

}