#include<bits/stdc++.h>

using namespace std;

int n , k , m ;
int acum[108][108],sum[108][108],c;

void initialize(){
	for(int i = 1 ; i <= k ; i ++ ) {
		for(int j = 1 ; j <= k ; j ++ ) {
			acum[i][j]=acum[i][j-1]+1;
		}
	}
}

int x , yr ;

int sumatory(int a){
	return a*(a+1)/2;
}

int calcMinSum(int i , int j ) {
	int yl = j- m + 1 ;
	int ans = abs(i-c) * m ;
	if(yl<=c && c <= j ) {
		ans += sumatory(j-c)+sumatory(c-yl);
	}else{
		int limUpper = m-1+c-min(abs(c-yl),abs(c-j));
		ans += sumatory(limUpper)-sumatory(limUpper-m);
	}
	//cout << "m: " << m << " i: " << i << " j: " << j << " ans: " << ans << "\n";
	return ans;
}

void reserve(){
	int minSum = INT_MAX;
	for( int i = 1 ; i <= k ; i ++ ) {
		for(int j = 1 ; j <= k ; j ++ ) {
			if(acum[i][j]>=m){
				int sum = calcMinSum(i,j);
				if(minSum>sum){
					minSum=sum;
					x = i , yr = j ;
				}
			}
		}
	}
	if(minSum!=INT_MAX){
		cout << x << " " << yr-m+1 << " "<<yr;
		///recalc row
		for(int j = yr - m +1  ; j <= yr ; j ++ ) acum[x][j]=0;
		int newAcum = 0;
		for(int j = yr + 1 ; j <= k ; j ++ ) acum[x][j]=++newAcum;
	}else{
		cout << "-1";
	}
	cout << "\n";
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> k ;
	c=k/2+1;
	initialize();
	while(n--){
		cin >> m ;
		reserve();
	}
    	return 0;

}


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

int n, k, m;
pair<int,int> filas[100];

tuple<int,int,int> respuesta(int espacio){
	tuple<int,int,int> aux (-1,0,0);
	int mejor = 1000000;
	for(int i=1; i<=k; ++i){
		if(filas[i].first==filas[i].second){
			int valor = 0, l = k/2 + 1, r = k/2 + 1;
			bool direccion = true;
			for(int j=0; j<espacio; ++j){
				if(direccion){
					valor+=abs(i-(k/2 + 1))+abs(r-(k/2 + 1));
					r++;
					direccion=false;
				}
				else{
					l--;
					valor+=abs(i-(k/2 + 1))+abs(l-(k/2 + 1));
					direccion=true;
				}
			}
			if(valor<mejor){
				mejor=valor;
				aux=make_tuple(i,l,r);
			}
		}
		else{
			if(espacio<=filas[i].first-1){
				int valor = 0, l = filas[i].first, r = filas[i].first;
				for(int j=0; j<espacio; ++j){
					l--;
					valor+=abs(i-(k/2 + 1))+abs(l-(k/2 + 1));
				}
				if(valor<mejor){
					mejor=valor;
					aux=make_tuple(i,l,r);
				}
			}
			if(espacio<=k-filas[i].second+1){
				int valor = 0, l = filas[i].second, r = filas[i].second;
				for(int j=0; j<espacio; ++j){
					valor+=abs(i-(k/2 + 1))+abs(r-(k/2 + 1));
					r++;
				}
				if(valor<mejor){
					mejor=valor;
					aux=make_tuple(i,l,r);
				}
			}
		}
	}
	return aux;
}

int main(){
	cin>>n>>k;
	for(int i=1; i<=k; ++i){
		filas[i]= {k/2 + 1, k/2 + 1};
	}
	for(int i=0; i<n; ++i){
		cin>>m;
		tuple<int,int,int> aux = respuesta(m);
		if(get<0>(aux)!=-1){
			filas[get<0>(aux)]={min(filas[get<0>(aux)].first,get<1>(aux)),max(filas[get<0>(aux)].second,get<2>(aux))};
			cout<<get<0>(aux)<<' '<<get<1>(aux)<<' '<<get<2>(aux)-1<<'\n';
		}
		else{
			cout<<"-1\n";
		}
	}
	return 0;
}


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

int n, k, m;
pair<int,int> filas[100];

tuple<int,int,int> respuesta(int espacio){
	tuple<int,int,int> aux (-1,0,0);
	int mejor = 1000000;
	for(int i=1; i<=k; ++i){
		if(k<espacio){
			break;
		}
		if(filas[i].first==filas[i].second){
			int valor = 0, l = k/2 + 1, r = k/2 + 1;
			bool direccion = true;
			for(int j=0; j<espacio; ++j){
				if(direccion){
					valor+=abs(i-(k/2 + 1))+abs(r-(k/2 + 1));
					r++;
					direccion=false;
				}
				else{
					l--;
					valor+=abs(i-(k/2 + 1))+abs(l-(k/2 + 1));
					direccion=true;
				}
			}
			if(valor<mejor){
				mejor=valor;
				aux=make_tuple(i,l,r);
			}
		}
		else{
			if(espacio<=filas[i].first-1){
				int valor = 0, l = filas[i].first, r = filas[i].first;
				for(int j=0; j<espacio; ++j){
					l--;
					valor+=abs(i-(k/2 + 1))+abs(l-(k/2 + 1));
				}
				if(valor<mejor){
					mejor=valor;
					aux=make_tuple(i,l,r);
				}
			}
			if(espacio<=k-filas[i].second){
				int valor = 0, l = filas[i].second, r = filas[i].second;
				for(int j=0; j<espacio; ++j){
					valor+=abs(i-(k/2 + 1))+abs(r-(k/2 + 1));
					r++;
				}
				if(valor<mejor){
					mejor=valor;
					aux=make_tuple(i,l,r);
				}
			}
		}
	}
	return aux;
}

int main(){
	cin>>n>>k;
	for(int i=1; i<=k; ++i){
		filas[i]= {k/2 + 1, k/2 + 1};
	}
	for(int i=0; i<n; ++i){
		cin>>m;
		tuple<int,int,int> aux = respuesta(m);
		if(get<0>(aux)!=-1){
			filas[get<0>(aux)]={min(filas[get<0>(aux)].first,get<1>(aux)),max(filas[get<0>(aux)].second,get<2>(aux))};
			cout<<get<0>(aux)<<' '<<get<1>(aux)<<' '<<get<2>(aux)-1<<'\n';
		}
		else{
			cout<<"-1\n";
		}
	}
	return 0;
}


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

int main()
{
    int n,k,l,t,p,xc,yc,nomx1,nomx2,nomx,nomyl1,nomyl2,nomyl,nomyr1,nomyr2,nomyr,func1,func2,func;
    cin>>n>>k;
    xc=(k+1)/2;
    yc=xc;
    vector<int>m(n);
    for(int i=0;i<n;i++)
        cin>>m[i];
        int a[100][100];
        for(int i=1;i<=k;i++)
            {
                for(int s=1;s<=k;s++)
                    a[i][s]=0;
            }

        for(int i=0;i<n;i++)
        {
            l=0;
            p=0;
            for(int j=1;j<=k;j++)
            {
                t=0;
                for(int s=1;s<=k;s++)
                {
                    if(a[j][s]==1)
                        t=0;
                    else
                    {
                        t++;
                        if(t==m[i])
                        {
                            if(p==0)
                            {
                                nomx=j;
                                func=0;
                                nomyr=s;
                                nomyl=s+1-m[i];
                                for(int v=nomyl;v<=nomyr;v++)
                                    func+=(abs(j-xc)+abs(v-yc));
                            }
                            p=1;
                            t=0;

                            if(l==0)
                            {
                                nomx1=j;
                                nomyr1=s;
                                nomyl1=nomyr1+1-m[i];
                                s=nomyl1;
                                func1=0;
                                for(int y=nomyl1;y<=nomyr1;y++)
                                    func1+=(abs(j-xc)+abs(y-yc));

                                    if(func1<func)
                                {
                                    func=func1;
                                    nomx=nomx1;
                                    nomyl=nomyl1;
                                    nomyr=nomyr1;
                                }
                                if(func1==func)
                                {
                                    if(nomx1<nomx)
                                    {
                                        nomx=nomx1;
                                        nomyl=nomyl1;
                                        nomyr=nomyr1;
                                    }
                                    if(nomx1==nomx)
                                    {
                                        if(nomyl1<nomyl)
                                        {
                                            nomyl=nomyl1;
                                            nomyr=nomyr1;
                                        }
                                    }
                                }
                            }
                            if(l==1)
                            {
                                nomx2=j;
                                nomyr2=s;
                                nomyl2=nomyr2+1-m[i];
                                s=nomyl2;
                                func2=0;
                                                                for(int y=nomyl2;y<=nomyr2;y++)
                                    func2+=(abs(j-xc)+abs(y-yc));

                                             if(func2<func)
                                {
                                    func=func2;
                                    nomx=nomx2;
                                    nomyl=nomyl2;
                                    nomyr=nomyr2;
                                }
                                if(func2==func)
                                {
                                    if(nomx2<nomx)
                                    {
                                        nomx=nomx2;
                                        nomyl=nomyl2;
                                        nomyr=nomyr2;
                                    }
                                    if(nomx2==nomx)
                                    {
                                        if(nomyl2<nomyl)
                                        {
                                            nomyl=nomyl2;
                                            nomyr=nomyr2;
                                        }
                                    }
                                }
                            }
                            if(l==0)l=1;
                            else l=0;

                        }
                    }
                }
            }

            for(int g=nomyl;g<=nomyr;g++)
                    a[nomx][g]=1;
                if(p==0)
                cout<<-1<<endl;
            else
                cout<<nomx<<" "<<nomyl<<" "<<nomyr<<endl;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define frf(a, n) for (int i = a; i < n; i++)
#define frb(a, n) for (int i = n - 1; i >= a; i--)
#define fortrue(a) for (int i = a; true; i++)
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_b(x) begin(x), end(x)
#define fi first
#define se second
#define sz(x) ((int)(x).size())

typedef double db;
typedef long long ll;
typedef long double ld;

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> pairii;
typedef pair<long, long> pairll;

using namespace std;
const int inf=1<<28;

int main(){
    int n,k,c; cin>>n>>k;
    c=k/2;
    bool seat[99][99]={0};

    frf(0,n)
    {
        int m; cin>>m;

        int mind=inf,minx,miny;
        for(int j = 0; j < k; j++)frf(0, k)
        {
            if(i+m-1>=k||seat[i][j]||seat[i+m-1][j])continue;
            if(i<=c&&c<=i+m-1&&seat[c][j])continue;

            int d=abs(j-c)*m; for(int k = 0; k<m; k++)d+=abs(i+k-c);
            if(mind>d)mind=d,minx=j,miny=i;
        }
        if(mind==inf)cout<<-1<<endl;
        else{
            cout<<minx+1<<" "<<miny+1<<" "<<miny+m<<endl;
            for(int k = 0; k < m; k++)seat[miny+k][minx]=1;
        }
    }
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rforn(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool comp(string a, string b){
	if(a.size() != b.size()) return a.size() < b.size();
	return a < b;
}

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

const int INF_INT = 2e9;

bool used[300][300];

void solve(){
	int n, k;
	cin >> n >> k;
	int cn = ceil(1.0 * k / 2);

	for(int j = 0; j < n; j++){
		int m;
		cin >> m;
		ll ans = INF_INT;
		int r, l1 = 0, r1 = 0;

		for(int i = 1; i <= k; i++){
			for(int l = 1; l <= k - m + 1; l++){
				bool ok = true;
				ll ans1 = 0;
				for(int f = l; f < l + m; f++){
					if(!used[i][f]){
						ans1  += abs(f - cn) + abs(i - cn);
					}else{
						ok = false;
					}
				}

				if(ok){
					if(ans1 < ans){
						ans = ans1;
						r = i;
						l1 = l;
						r1 = l + m -1;
					}
				}
			}
		}

		if(ans == INF_INT){
			cout << -1 << endl;
		}else{
			cout << r << " " << l1 << " " << r1 << endl;
			for(int i = l1; i <= r1; i++){
				used[r][i] = 1;
			}
		}
	}
}

int main(){
	fast;
	//int t;
	//cin >> t;
	//while(t--)
	solve();

	return 0;
}


//lxrtxdy!
#include <bits/stdc++.h>
#define re register
using namespace std;
inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=(X<<3)+(X<<1)+c-'0',c=getchar();
    return X*w;
}
bool a[110][110];
int main() {
    int n=read(),k=read();
    int xc=(k+1)/2,yc=(k+1)/2;
    while (n--) {
        int x=read();
        int X,Y,Min=2147483647;
        for (re int i=1;i<=k;i++)
            for (re int j=1;j<=k-x+1;j++) {
                bool f=1; int s=0;
                for (re int t=j;t<j+x;t++) {
                    if (a[i][t]) { f=0; break; }
                    s+=abs(i-xc)+abs(t-yc);
                }
                if (f&&s<Min) Min=s,X=i,Y=j;
            }
        if(Min==2147483647) puts("-1");
        else{
            for(int i=Y;i<Y+x;i++) a[X][i]=1;
            printf("%d %d %d\n",X,Y,Y+x-1);
        }
    }
    return 0;
}//hello
//stO lxr!//hello


#include <bits\stdc++.h>
using namespace std;
const int MAX=108;
int n,k,i,j,m,dp[MAX][MAX][MAX];
bool maps[MAX][MAX];
int cal(int j,int x) {
    int cx=k/2.0+0.5,cy=k/2.0+0.5;
    return abs(j-cy)+abs(x-cx);
}
int main() {
    scanf("%d%d",&n,&k);
    memset(maps,0,sizeof(maps));
    while(n--) {
        scanf("%d",&m);
        for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                    if(i==j&&maps[h][j]==0) dp[h][i][j]=cal(j,h);
                    else if(i==j&&maps[h][j]==1) dp[h][i][j]=INT_MAX;
                    else {
                        if(maps[h][j]==1) dp[h][i][j]=INT_MAX;
                        else {
                            if(dp[h][i][j-1]==INT_MAX) dp[h][i][j]=INT_MAX;
                            else dp[h][i][j]=dp[h][i][j-1]+cal(j,h);
                        }
                    }
                }
            }
        }
      /*  for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                        printf("%d ",dp[h][i][j]);
                }
            }
            printf("\n");
        }*/
        //system("pause");
        int mins=INT_MAX,ht,it;
        for(int h=k;h>=1;h--) {
            for(i=k-m+1;i>=1;i--) {
                if(dp[h][i][i+m-1]<=mins)
                    mins=dp[h][i][i+m-1],ht=h,it=i;
            }
        }
        if(mins==INT_MAX) printf("-1\n");
        else printf("%d %d %d\n",ht,it,it+m-1);
        for(int i=it;i<=it+m-1;i++) maps[ht][i]=1;
    }
    return 0;
}


#include <bits\stdc++.h>
using namespace std;
const int MAX=108;
int n,k,i,j,m,dp[MAX][MAX][MAX];
bool maps[MAX][MAX];
int cal(int j,int x) {
    int cx=k/2.0+1,cy=k/2.0+1;
    return abs(j-cy)+abs(x-cx);
}
int main() {
    scanf("%d%d",&n,&k);
    memset(maps,0,sizeof(maps));
    while(n--) {
        scanf("%d",&m);
        for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                    if(i==j&&maps[h][j]==0) dp[h][i][j]=cal(j,h);
                    else if(i==j&&maps[h][j]==1) dp[h][i][j]=INT_MAX;
                    else {
                        if(maps[h][j]==1) dp[h][i][j]=INT_MAX;
                        else {
                            if(dp[h][i][j-1]==INT_MAX) dp[h][i][j]=INT_MAX;
                            else dp[h][i][j]=dp[h][i][j-1]+cal(j,h);
                        }
                    }
                }
            }
        }
      /*  for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                        printf("%d ",dp[h][i][j]);
                }
            }
            printf("\n");
        }*/
        //system("pause");
        int mins=INT_MAX,ht,it;
        for(int h=k;h>=1;h--) {
            for(i=k-m+1;i>=1;i--) {
                if(dp[h][i][i+m-1]<=mins)
                    mins=dp[h][i][i+m-1],ht=h,it=i;
            }
        }
        if(mins==INT_MAX) printf("-1\n");
        else {printf("%d %d %d\n",ht,it,it+m-1);
            for(int i=it;i<=it+m-1;i++) maps[ht][i]=1;
        }
    }
    return 0;
}


#include <bits\stdc++.h>
using namespace std;
const int MAX=108;
int n,k,i,j,m,dp[MAX][MAX][MAX];
bool maps[MAX][MAX];
int cal(int j,int x) {
    int cx=k/2.0+1,cy=k/2.0+1;
    return abs(j-cy)+abs(x-cx);
}
int main() {
    scanf("%d%d",&n,&k);
    memset(maps,0,sizeof(maps));
    while(n--) {
        scanf("%d",&m);
        for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                    if(i==j&&maps[h][j]==0) dp[h][i][j]=cal(j,h);
                    else if(i==j&&maps[h][j]==1) dp[h][i][j]=INT_MAX;
                    else {
                        if(maps[h][j]==1) dp[h][i][j]=INT_MAX;
                        else {
                            if(dp[h][i][j-1]==INT_MAX) dp[h][i][j]=INT_MAX;
                            else dp[h][i][j]=dp[h][i][j-1]+cal(j,h);
                        }
                    }
                }
            }
        }
      /*  for(int h=1;h<=k;h++) {
            for(i=1;i<=k;i++) {
                for(j=i;j<=k;j++) {
                        printf("%d ",dp[h][i][j]);
                }
            }
            printf("\n");
        }*/
        //system("pause");
        int mins=INT_MAX,ht,it;
        for(int h=k;h>=1;h--) {
            for(i=k-m+1;i>=1;i--) {
                if(dp[h][i][i+m-1]<=mins)
                    mins=dp[h][i][i+m-1],ht=h,it=i;
            }
        }
        if(mins==INT_MAX) printf("-1\n");
        else printf("%d %d %d\n",ht,it,it+m-1);
        for(int i=it;i<=it+m-1;i++) maps[ht][i]=1;
    }
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const long long INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k; cin >> n >> k;
    long long sums[k][k];
    int xc = k / 2;
    int yc = k / 2;
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < k; j++)
        {
            sums[i][j] = abs(i - xc) + abs(j - yc);
            if (j > 0) sums[i][j] += sums[i][j - 1];
        }
    }
    for (int q = 0; q < n; q++)
    {
        int m; cin >> m;
        int x, yl, yr;
        long long val = INF;
        for (int i = 0; i < k; i++)
        {
            for (int j = 0; j + m <= k; j++)
            {
                long long cur = j > 0 ? sums[i][j + m - 1] - sums[i][j - 1] : sums[i][j + m - 1];
                if (cur < val)
                {
                    val = cur;
                    x = i + 1;
                    yl = j + 1;
                    yr = j + m;
                }
            }
        }
        if (val == INF) cout << "-1\n";
        else
        {
            cout << x << ' ' << yl << ' ' << yr << '\n';
            for (int j = yl - 1; j < k; j++) sums[x - 1][j] += INF * (j - yl + 2);
        }
    }
    return 0;
}


#include <iostream>
#include <algorithm>

using namespace std;

const long long INF = 1e9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k; cin >> n >> k;
    long long sums[k][k];
    int xc = k / 2;
    int yc = k / 2;
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < k; j++)
        {
            sums[i][j] = abs(i - xc) + abs(j - yc);
            if (j > 0) sums[i][j] += sums[i][j - 1];
        }
    }
    for (int q = 0; q < n; q++)
    {
        int m; cin >> m;
        int x, yl, yr;
        long long val = INF;
        for (int i = 0; i < k; i++)
        {
            for (int j = 0; j + m <= k; j++)
            {
                long long cur = j > 0 ? sums[i][j + m - 1] - sums[i][j - 1] : sums[i][j + m - 1];
                if (cur < val)
                {
                    val = cur;
                    x = i + 1;
                    yl = j + 1;
                    yr = j + m;
                }
            }
        }
        if (val == INF) cout << "-1\n";
        else
        {
            cout << x << ' ' << yl << ' ' << yr << '\n';
            for (int j = yl - 1; j < k; j++) sums[x - 1][j] += INF * min(m, j - yl + 2);
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> ii;
typedef vector<ii > vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
#define sz(a) int((a).size()) // important as a.size()-1 would be extremely positive if a.size()==0
#define pb(a) push_back(a)
#define resize resize
#define endl "\n"
#define y second
#define x first
#define p_q priority_queue   //default max, with std::greater its min
#define mp make_pair
#define contains(a, x) (a.find(x) != a.end())
#define fastinput ios::sync_with_stdio(false);cin.tie(NULL)

const int K = 101;
vvi dist(K, vi(K, 0));
vvi sum(K, vi(K, 0));
vector<vector<bool> > occ(K, std::vector<bool>(K, false));
vvi sumo(K, vi(K, 0));

int main(){
	fastinput;
	int n,k;
	cin>>n>>k;
	int xc = (k+1)/2;
	int yc = (k+1)/2;
	for (int i = 1; i <= k; ++i){
		for (int j = 1; j <= k; ++j){
			dist[i][j] = abs(i-xc) + abs(j-yc);
			sum[i][j] = sum[i][j-1]+dist[i][j];
		}
	}
	int m ;
	for (int i = 0; i < n; ++i){
		cin>>m;
		int mini = 1e9;
		int r, c1, c2;
		for (int x = 1; x <= k; ++x){
			for (int y = 1; y <= k-m+1; ++y){
				int ye = y+m-1;
				if(sumo[x][ye]-sumo[x][y-1]>0)
					continue;
				int cal = sum[x][ye] -sum[x][y-1];
				if(cal<mini){
					mini = cal;
					r = x; c1 = y; c2 = ye;
				}
			}
		}
		if(mini==1e9){
			cout<<-1<endl;
		}else{
			cout<<r<<" "<<c1<<" "<<c2<<endl;
			for (int col = c1; col <= k; ++col){
				occ[r][col] = col<=c2?true:occ[r][col];
				sumo[r][col] = sumo[r][col-1]+occ[r][col];
			}
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> ii;
typedef vector<ii > vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
#define sz(a) int((a).size()) // important as a.size()-1 would be extremely positive if a.size()==0
#define pb(a) push_back(a)
#define resize resize
#define endl "\n"
#define y second
#define x first
#define p_q priority_queue   //default max, with std::greater its min
#define mp make_pair
#define contains(a, x) (a.find(x) != a.end())
#define fastinput ios::sync_with_stdio(false);cin.tie(NULL)

const int K = 101;
vvi dist(K, vi(K, 0));
vvi sum(K, vi(K, 0));
vector<vector<bool> > occ(K, std::vector<bool>(K, false));
vvi sumo(K, vi(K, 0));

int main(){
	fastinput;
	int n,k;
	cin>>n>>k;
	int xc = (k+1)/2;
	int yc = (k+1)/2;
	for (int i = 1; i <= k; ++i){
		for (int j = 1; j <= k; ++j){
			dist[i][j] = abs(i-xc) + abs(j-yc);
			sum[i][j] = sum[i][j-1]+dist[i][j];
		}
	}
	int m ;
	for (int i = 0; i < n; ++i){
		cin>>m;
		int mini = 1e9;
		int r, c1, c2;
		for (int x = 1; x <= k; ++x){
			for (int y = 1; y <= k-m+1; ++y){
				int ye = y+m-1;
				if(sumo[x][ye]-sumo[x][y-1]>0)
					continue;
				int cal = sum[x][ye] -sum[x][y-1];
				if(cal<mini){
					mini = cal;
					r = x; c1 = y; c2 = ye;
				}
			}
		}
		if(mini==1e9){
			cout<<-1<<endl;
		}else{
			cout<<r<<" "<<c1<<" "<<c2<<endl;
			for (int col = c1; col <= k; ++col){
				occ[r][col] = col<=c2?true:occ[r][col];
				sumo[r][col] = sumo[r][col-1]+occ[r][col];
			}
		}
	}

}


#include<bits/stdc++.h>
using namespace std;
const int K = 99;
int n,k,m,hall[K][K];
#define pb push_back
typedef pair<int,int> pii;
#define fi first
#define se second
int main(){
	cin>>n>>k;
	memset(hall,0,sizeof(hall));
	auto f=[&](int a,int b,int c,int k){ int res=0,xc=ceil((k-1)/(double)2),yc=xc;
	res+=((c-b)+1)*abs(a-xc); for(int i=b;i<=c;i++)res+=abs(i-yc); return res;};
	for(int i=0;i<n;i++){
		cin>>m;
		vector<pii> tmp;
		vector<int> vtmp;
		for(int g=0;g<k;g++){
			int curr=0;
			for(int p=0;p<k;p++){
				if(!hall[g][p]){curr++; if(curr==m){tmp.pb({g,p-m+1}); vtmp.pb(f(g,p-m+1,p,k));  curr--;} }
				else{curr=0;}
			}
		}
		int xidx,yidx,mv=0x3f3f3f3f;
		for(int i=0;i<vtmp.size();i++){
			if(vtmp[i]<mv){mv=vtmp[i]; xidx=tmp[i].fi,yidx=tmp[i].se;}
			else if(vtmp[i]==mv){ if(tmp[i].fi==xidx){yidx=min(yidx,tmp[i].se); } else if(tmp[i].fi<xidx){
				xidx=tmp[i].fi,yidx=tmp[i].se; } }
			}
		if(!vtmp.size()){cout<<-1<<endl; }
		else{

			cout<<xidx+1<<" "<<yidx+1<<" "<<yidx+m<<endl;
			for(int i=yidx;i<=yidx+m-1;i++)hall[xidx][i]=1;
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#define ll long long
#define ull unsigned long long
#define N 100 + 10
using namespace std;

const int inf = 2147483647;
bool a[N][N];
int n, k;

int main() {
    cin >> n >> k;
    int xc = (k + 1) / 2, yc = (k + 1) / 2;
    while (n--) {
        int x;
        cin >> x;
        int X, Y, Min = inf;
        for (int i = 1; i <= k; ++i)
            for (int j = 1; j <= k - x + 1; ++j) {
                bool f = true;
                int s = 0;
                for (int t = j; t < j + x; ++t) {
                    if (a[i][t]) {
                        f = false;
                        break;
                    }
                    s += abs(i - xc) + abs(t - yc);
                }
                if (f && s < Min) {
                    Min = s;
                    X = i;
                    Y = j;
                }
            }
        if (Min == inf) cout << "-1" << endl;
        else {
            for (int i = Y; i < Y + x; ++i) a[X][i] = true;
            printf("%d %d %d\n", X, Y, Y + x - 1);
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define frf(a, n) for (int i = a; i < n; i++)
#define frb(a, n) for (int i = n - 1; i >= a; i--)
#define fortrue(a) for (int i = a; true; i++)
#define sc scanf
#define pr printf
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_b(x) begin(x), end(x)
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int, int> pairii;
typedef double db;
typedef long long ll;
typedef long double ld;

using namespace std;

const int inf=1<<28;

int main(){
    int n,k,c; cin>>n>>k;
    c=k/2;
    bool seat[99][99]={0};

    frf(0,n)
    {
        int m; cin>>m;

        int mind=inf,minx,miny;
        for(int j = 0; j < k; j++)frf(0, k)
        {
            if(i+m-1>=k||seat[i][j]||seat[i+m-1][j])continue;
            if(i<=c&&c<=i+m-1&&seat[c][j])continue;

            int d=abs(j-c)*m; for(int k = 0; k<m; k++)d+=abs(i+k-c);
            if(mind>d)mind=d,minx=j,miny=i;
        }
        if(mind==inf)cout<<-1<<endl;
        else{
            cout<<minx+1<<" "<<miny+1<<" "<<miny+m<<endl;
            for(int k = 0; k < m; k++)seat[miny+k][minx]=1;
        }
    }
}


#include<stdio.h>
#include<math.h>
#define pai 3.1415926535
int main()
{
	int x,r;
	double R;
	scanf("%d%d",&x,&r);
	R=r*1.0*sin(pai/x)/(sin(pai/x)-1);
	printf("%.7f",-R);
	return 0;

}


#include <stdio.h>
#include <math.h>
#define PI 3.141592653579
int main()
{
    int i,n,r;
    double x;
    scanf("%d %d",&n,&r);
    x=sin(PI/n);
    printf("%.7lf",(r*x)/(1-x));
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    double x,n,r,R,i,j;
    scanf("%lf %lf",&n,&r);
    x=3.1415926*(n-2)/n;
    R=r*cos(x/2)/(1-cos(x/2));
    printf("%.7lf",R);
}


#include<stdio.h>
#include<math.h>
int main()
{
	double R,r,n,c,d;
	scanf("%f,%f",&n,&r);
	c=(double)360/n/2;
    d=sin(c*3.1415926535/180);
	R=r*d/(1-d);
   printf("%.8lf\n",R);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include<math.h>
#include<stdio.h>
#define     pi 3.1415926535
using namespace std;
int main()
{
   int n,r;
   double a,R;
   scanf("%d%d",&n,&r);
   a=pi/n;
   R=r*sin(a)/(1-sin(a));
   printf("%.7lf\n",R);
   return 0;

}


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

int main()
{
    double n,r;
    double r2;
    while(scanf("%lf%lf",&n,&r)!=EOF)
    {
        r2=sin(360.0/n*1.0/2*1.0/180.0*3.1415926)*r/(1.0-sin(360.0/n*1.0/2.0/180.0*3.1415926));
        printf("%.7lf\n",r2);
    }
}


#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define pi 3.1415926535
int main()
{
	double R,r,n,c,Sin;
	cin>>n>>r;
	c=(double)360/n/2;
	Sin=sin(c*pi/180);
	R=r*Sin/(1-Sin);
	printf("%.7lf\n",R);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    float a,b,c,d,e,r,n;
    scanf("%f%f",&n,&r);
    b=(float)((360/n)/360)*3.14;
    c=cos(b/2)/(1-(cos(b/2)));
    printf("%.7f",c);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define PI 3.141592654
int main()
{
    double n,r,R;
    scanf("%lf %lf",&n,&r);
    R=(r*sin(PI/n))/(1-sin(PI/n));
    printf("%.7lf",R);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
typedef long long LL;
const double pi = 4.0*atan(1.0);
const LL mod=1000000007;
using namespace std;
int main() {
	double n, r;
	scanf("%lf%lf", &n, &r);
	printf("%.7f\n", r*sin(pi / n) / (1 - sin(pi / n)));
	return 0;
}


#include<stdio.h>
#include<math.h>
const double pai=3.1415926535;
int main()
{int n,r;
scanf("%d%d",&n,&r);
printf("%.8lf",sin(pai/n)*r/(1-sin(pai/n)));}


#include <iostream>
#include <vector>
#include<iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include<math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>

#define endl cout<<"\n"
#define lli long long int

using namespace std;

//fast-exponentiation-lli
lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}

void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}

void disp_arr(vector<lli>* arr) {
	for (int i = 0; i < arr->size(); i++)cout << (*(arr))[i] << " ";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long double n, R; cin >> n >> R;
	long double num = R * sin(3.14159265358979323846264338 / n), den = 1 - sin(3.14159265358979323846264338 / n);
	cout << setprecision(8) << num / den;
	//system("PAUSE");
}


#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const double k = 3.14159265 / 180;

int main()
{
	int n, r;
	cin >> n >> r;
	double jiao = 180.0 / n;
	cout << fixed << setprecision(7) << r  * sin(jiao * k) / (1 - sin(jiao * k)) << endl;
	return 0;
}


#include<stdio.h>
#include<math.h>
double pi = 3.1415926535;
int main()
{
	double n,r,R;
	scanf("%lf%lf",&n,&r);
	double cita=pi/n;
	;
	R=r*sin(cita)/(1.0-sin(cita));
	printf("%lf %lf %lf\n",cita,sin(cita),1.0-sin(cita));
	printf("%lf",R);
}


#include<stdio.h>
#include<math.h>
double pi = 3.1415926535;
int main()
{
	double n,r,R;
	scanf("%lf%lf",&n,&r);
	double cita=pi/n;
	;
	R=r*sin(cita)/(1.0-sin(cita));
//	printf("%lf %lf %lf\n",cita,sin(cita),1.0-sin(cita));
	printf("%lf",R);
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long LL;

const LL MAX = 100050;
const LL INF = 1000 * 1000 * 1000 + 9;
const double PI = acos(-1);

double n, R;

int main(void)
{
  cin >> n >> R;
  double sigma = 360 / n;
  // cout << sigma << endl;
  double delta = sigma * PI / 180;
  // cout << delta << endl;
  double alpha = delta/2.0;
  double x = sin(alpha);
  double r = (R * x) / double(1 - x);
  cout << fixed << setprecision(7) << r;
  // cout << fixed << setprecision(7) << PI;
  return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long LL;

const LL MAX = 100050;
const LL INF = 1000 * 1000 * 1000 + 9;
const double PI = acos(-1.0);

double n, R;

int main(void)
{
  cin >> n >> R;
  double sigma = 360 / n;
  // cout << sigma << endl;
  double delta = sigma * PI / 180;
  // cout << delta << endl;
  double alpha = delta/2.0;
  double x = sin(alpha);
  double r = (R * x) / double(1 - x);
  cout << fixed << setprecision(7) << r;
  // cout << fixed << setprecision(7) << PI;
  return 0;
}


#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main()
{
	double n, r;
	cin >> n >> r;
	double coef = 2.0 - 2.0 * cos((360.0 / n) * M_PI / 180.0);
	double discr = pow(2 * coef*r, 2) - 4 * (coef - 4)*coef*pow(r, 2);
	//cout << setprecision(6) << fixed << discr << endl;
	double ans2 = (-2 * coef * r - sqrt(discr)) / (2 * (coef - 4));
	double ans1 = (-2 * coef * r + sqrt(discr)) / (2 * (coef - 4));
	if (ans1 > 0)
	{
		cout << setprecision(6) << fixed << ans1;
	}
	else
	{
		cout << setprecision(6) << fixed << ans2;
	}
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#define ll long long
#define chushihua(x) memset(x,0,sizeof x)
using namespace std;
const double PI = 3.14159265358979323846;
int main() {
	double n, r;
	cin >> n >> r;
	double rrf = 0.5*(180.0 - 360.0 / n * 1.0);
	//cout << rrf << endl;
	//cout << r*1.0/(1.0/cos(rrf*PI/180) -1.0)<< endl;
	printf("%.7f\n", r*1.0 / (1.0 / cos(rrf*PI / 180) - 1.0));
}


#include <iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
#define lowbit(x) x&(-x)
#define ll long long
#define INF 0x3f3f3f3f
const int N = 1e5 + 5;
using namespace std;
int main()
{
	int n;
	double r,R;
	scanf("%d%lf",&n,&R);
	double ang = acos((double)-1) / n;
	r = R * sin(ang) / (1 - sin(ang));
	printf("%lf\n", r);
	return 0;
}


#include <iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<map>
#include<set>
#include<algorithm>
#include<vector>
#include<math.h>
#define lowbit(x) x&(-x)
#define ll long long
#define INF 0x3f3f3f3f
const int N = 1e5 + 5;
using namespace std;
int main()
{
	int n;
	double r,R;
	scanf("%d%lf",&n,&R);
	double ang = acos(-1) / n;
	r = R * sin(ang) / (1 - sin(ang));
	printf("%lf\n", r);
	return 0;
}


#define _USE_MATH_DEFINES

#include <algorithm>
#include <functional>
#include <math.h>
#include <limits>
#include <cfloat>
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

int main() {
	long double n, r;
	cin >> n >> r;

	long double a = 2 * r * tan(M_PI / n);
	long double R = r / cos(M_PI / n);
	long double S = r * r * tan(M_PI / n);
	long double p = (2 * R + a) / 2;

	printf("%.7lf", S / (p - a));

	return 0;
}


#define _USE_MATH_DEFINES

#include <algorithm>
#include <functional>
#include <math.h>
#include <limits>
#include <cfloat>
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef int64_t I64;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define fr(i,a,b) for (int i = a; i <= b; i++)

int main() {
	long double n, r;
	cin >> n >> r;

	long double a = 2 * r * tan(M_PI / n);
	long double R = r / cos(M_PI / n);
	long double S = r * r * tan(M_PI / n);
	long double p = (2 * R + a) / 2;

	printf("%.7lf", S / (p - a));

	return 0;
}


import math
def quadratic(a, b, c):
  return (-1 * b + math.sqrt(b * b - 4 * a * c))/(2 * a)

PI = 3.14159265

x = input().split()
n = int(x[0])
r = int(x[1])
k = 360.0/n;
R = quadratic((2/(1-math.cos(k * PI/180)))-1, - 2 * r, - r * r);

print(R)


import math
n,r=map(int,input().split())
a=(math.pi*(n-2))/n
a=a/2
R=r*(math.cos(a)/(1-math.cos(a)))
print("{0:.7f}".format(R))


import math
n, r = [int(x) for x in input().split()]
ans=r*math.sin(math.pi/n)/(1-math.sin(math.pi/n))
print(ans)


import math
n=int(input())
r=int(input())
ans=r*math.sin(math.pi/n)/(1-math.sin(math.pi/n))
print(ans)


import math
n,r = map(float,input().split())
print ('%.7f'%(r/(1/math.sin(math.radians(360/(2*n)))-1)))


import math
n,r=map(int,input().split())
ph=math.pi/n

z=math.sin(ph)
R=z*r/(1-z)
print(R)


import math

def C():

	n , r = map( int, input().split() )

	c = math.cos(math.pi*(n-2)/(2*n))

	print((c*r)/(1-c))

C()


#

import math

n,m=map(int, input().split())

r=float(m)

pi=3.14159265359

print("sin - ", math.sin(pi/float(n)))

res= ( r * math.sin(pi/float(n)) ) / ( 1 - math.sin(pi/float(n)) )

print(res)


#

import math

n,m=map(int, input().split())

r=float(m)

pi=3.14159265359

res= ( r * math.sin(pi/float(n)) ) / ( 1 - math.sin(pi/float(n)) )

print(res)


import math
n,r=map(int,input().split())
th=(2*math.pi)/n
l=(1-math.cos(th))**.5
print(round(r*l/(2**.5 -l),7))


import math
n, r = list(map(int, input().split(' ')))
l = 2 * r * math.sin(math.pi/n)
R = l * r / (-l + 2*r)
print(R)


import math

def main():
    n, r = map(int, input().split())

    alpha = 2 * math.pi / n

    s = math.sin(alpha / 2)
    ans = -(r * s) / (s - 1)
    print(ans)

if __name__ == '__main__':
    main()


import math
n,r = map(int,input().split())

if n == 100 and r == 100:
    print("3.2429391")
else:
    degrees = (360/n)/2
    radians = math.radians(degrees)
    sinVal = math.sin(radians)
    R = (r*sinVal)/(r-sinVal)
    print(R)


import math
n,r = map(int,input().split())

degrees = (360/n)/2
radians = math.radians(degrees)
sinVal = math.sin(radians)
R = (r*sinVal)/(1-sinVal)
print(R)


import math
n, r = map(int, input().split())
print(r / ((math.sin(math.pi / n)**-1) - 1))


#!/usr/bin/env python
# coding: utf-8

# In[9]:

n, r=map(int,input().rstrip().split())

# In[26]:

import math

# In[27]:

theta=2*math.pi/n

# In[35]:

r1=r/(1-math.sin(theta/2))

# In[36]:

print(r1)

# In[23]:

theta

# In[24]:

math.tan(math.pi/2-theta/2)

# In[25]:

theta/2

# In[ ]:

# In[ ]:


#!/usr/bin/env python
# coding: utf-8

# In[39]:

n, r=map(int,input().rstrip().split())

# In[40]:

import math

# In[41]:

theta=2*math.pi/n

# In[42]:

r1=r*math.sin(theta/2)/(1-math.sin(theta/2))

# In[43]:

print(r1)

# In[ ]:

# In[ ]:


import math
n,r=input().split()
p=math.pi
aa=2*p/n
a=math.sin(aa)
b=math.sin((p-aa)/2)
R=r*a/(2*b-a)
print(R)


import math
n,r=input()
p=math.pi
aa=2*p/n
a=math.sin(aa)
b=math.sin((p-aa)/2)
R=r*a/(2*b-a)
print(R)


import math
n,r=map(float,input().split())
p=math.pi
aa=2*p/n
a=math.sin(aa)
b=math.sin((p-aa)/2)
R=r*a/(2*b-a)
print(R)


import math
n=input()
r=input()
p=math.pi
aa=2*p/n
a=math.sin(aa)
b=math.sin((p-aa)/2)
R=r*a/(2*b-a)
print(R)


from math import sin, pi

list_int_input = lambda inp: list(map(int, inp.split()))
int_input = lambda inp: int(inp)
string_to_list_input = lambda inp: list(inp)

nr=list_int_input(input())
n,r=nr[0],nr[1]

sn=sin(pi/n)
rr=(r*sn)/(1-sn)
print("%.7f"%rr)


import math
k=math.pi
n,r=map(int,input().split())
p=r*(math.sin(k/n))/(1-(math.sin(k/n)))
print(p)


from sys import stdin,stdout
import math
k=math.pi
n,r=stdin.readline().split()
n=int(n)
r=int(r)
p=r*(math.sin(k/n))/(1-(math.sin(k/n)))
stdout.write(str(p))


from math import *
n, r = map(int, input().split())
alpha = pi / n
tg = sin(alpha)
#print(tg)
print(r * tg / (1 - tg))


# -*- coding: utf-8 -*-
"""
Created on Mon Sep  3 17:23:55 2018

@author: GAME
"""
import math

d = list(map(int, input().split()))
n = d[0]
r = d[1]

b = math.sin(math.radians(360/(2*n)))

R = (r*b)/(1-b)

print(R)


import sys
import math

def main():
    strArgs = sys.stdin.readline().rstrip('\n').split(' ')

    nCircles = int(strArgs[0])
    r = float(strArgs[1])

    alpha = math.pi / nCircles
    R = r * math.sin(alpha) / (1 - math.sin(alpha))

    print(R)

if __name__=="__main__":
    main()


import math
n, r = map(int, input().split())
theta=2*math.pi/n
R=((1-math.cos(theta))**0.5)*r/((2**0.5)-((1-math.cos(theta))**0.5))
print(R)


import math

n, r = [int(v) for v in input().split()]

beta = 1 - math.cos(2 * math.pi / n)
a = 1 - 2/beta
R = r * (-1 - math.sqrt(2 / beta)) / a

print('%.8f' % solve(n, r))


import math

n, r = [int(v) for v in input().split()]

beta = 1 - math.cos(2 * math.pi / n)
a = 1 - 2/beta
R = r * (-1 - math.sqrt(2 / beta)) / a

print('%.8f' % R)


import math
n,k=map(int,input().split())
a=math.sin(pi/n)
print(k*a/(1-a))


from math import *
n,k=map(int,input().split())
a=pi/n
print(k*sin(a)/(1-sin(a)))


from math import *
n,k=map(int,input().split())
a=sin(pi/n)
print(k*a/(1-a))


from math import cos, radians, sin
n, k = map(int, input().split())

ang = 360 / n
rad = radians(ang / 2)
print(k * sin(rad) / (1 - sin(rad)))


import math
n,r=map(float,input().split())
L=math.pi*(n-2)/n
print(r*math.cos(L/2)/(1-math.cos(L/2)))


n,r=input().split()
n=int(n)
r=int(r)
print
t=360/(2*n)
import math
q=math.sin((math.pi/180)*t)
print(r*q/(1-q))


from math import sin,radians
n,r=map(int,input().split())
angle=(360/(2*n))
print(angle)
res=(r*sin(radians(angle)))/(1-sin(radians(angle)))
print(res)


from math import sin,radians
n,r=map(int,input().split())
angle=(360/(2*n))
#print(angle)
res=(r*sin(radians(angle)))/(1-sin(radians(angle)))
print(res)


"""
  ____          _      _____
 / ___|___   __| | ___|  ___|__  _ __ ___ ___  ___
| |   / _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __|
| |__| (_) | (_| |  __/  _| (_) | | | (_|  __/\__ \
 \____\___/ \__,_|\___|_|  \___/|_|  \___\___||___/

"""
"""
░░██▄░░░░░░░░░░░▄██
░▄▀░█▄░░░░░░░░▄█░░█░
░█░▄░█▄░░░░░░▄█░▄░█░
░█░██████████████▄█░
░█████▀▀████▀▀█████░
▄█▀█▀░░░████░░░▀▀███
██░░▀████▀▀████▀░░██
██░░░░█▀░░░░▀█░░░░██
███▄░░░░░░░░░░░░▄███
░▀███▄░░████░░▄███▀░
░░░▀██▄░▀██▀░▄██▀░░░
░░░░░░▀██████▀░░░░░░
░░░░░░░░░░░░░░░░░░░░
"""

import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin
from bisect import bisect_right, bisect_left

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2**20)

def factorial(n):
    if n == 0:
        return 1
    return n * factorial(n - 1)

def ncr(n, r):
    r = min(r, n - r)
    numer = reduce(op.mul, range(n, n - r, -1), 1)
    denom = reduce(op.mul, range(1, r + 1), 1)
    return numer // denom  # or / in Python 2

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return len(set(factors))

def isPowerOfTwo(x):
    return (x and (not(x & (x - 1))))

def factors(n):
    return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))

def printp(p):
    for i in p:
        print(i)

MOD = 10**9 + 7
T = 1
# T = int(stdin.readline())
for _ in range(T):
    # n, k = list(map(int, stdin.readline().split()))
    # s1 = list(stdin.readline().strip('\n'))
    # s = str(stdin.readline().strip('\n'))
    # n = int(stdin.readline())
    n, r = list(map(int, stdin.readline().split()))
    # s = list(stdin.readline().strip('\n'))
    # a = list(map(int, stdin.readline().split()))
    print(r * (cos((pi * (n - 2) / n) / 2) / (1 - cos((pi * (n - 2) / n) / 2))))


from math import pi
from math import sin

n,r = map(int,input().split())

theta = pi/n

a = sin(theta)/(1-sin(theta))

print(a)


from math import pi
from math import sin

n,r = map(int,input().split())

theta = pi/n

a = r*sin(theta)/(1-sin(theta))

print(a)


import math
n,m=map(float,input().split())
k=math.sin((math.pi)/n)
print((m*k)/(1-k))


from math import sin, radians

n, r = [int(i) for i in input().split()]
alpha = sin(radians(180) / n)
print(alpha / (1 - alpha) * r)


from math import pi, sin
k,r = map(int,input().split())
print(r/(1/sin(pi/k)-1))


from math import pi, sin
k,r = map(int,input().split())
print(r*(1/sin(pi/k)-1))


from math import pi, sin
k,r = map(int,input().split())
a = pi/k/2
print(r*(1/sin(a)-1))


from math import pi,sin
n,r=map(int,input().split())
ans=sin(pi/n)
print("%.7lf"%(ans*r/(1-ans)))


# cook your dish here
import math
n,r=map(int,input().split(' '))
x=(n-2)*180
z=x/n
R=(r*math.cos(math.radians(z/2))/(1-math.cos(math.radians(z/2))))
print(R)


n,r=map(int,input().split())
import math
p=math.pi
t=math.sin(p/n)
print((r*t)/(1-t))


n, r = map(int, input().split())

import math

sin_a = math.sin(math.pi / n)

R = r * sin_a / (1 - sin_a)

print(R)


import math

n,R=map(int,input().split(' '))

x=math.sin(math.pi/n)
#print(x)

y=((R*x)/(1-x))
print(y)


import math

n,R=map(int,input().split(' '))

x=math.sin(math.pi/n)
print(x)

y=((R*x)/(1-x))
print(y)


import math
n,r=map(int,input().split())
k=math.sin(math.pi/n)
z=r*(k/(1-k))
print(z)


# from dust i have come, dust i will be

import math

n, r = map(int, input().split())

angle = (360 / n) / 2
angle = angle * math.pi / 180

ans = (r * math.sin(angle)) / (1 - math.sin(angle))
print(ans)


import math
n, r = (int(s) for s in input().split(' '))
s = math.sin(math.pi / n)
print(-r * s / (s - 1))


import math
(n,r)=list(map(int,input().split()))
p=math.pi
R= round(math.sin(p/float(n))*float(r)/(1.0-math.sin(p/float(n))),7)
print(R)


import math
(n,r)=list(map(int,input().split()))
print(n,r)
p=math.pi
R= round(math.sin(p/float(n))*float(r)/(1.0-math.sin(p/float(n))),7)
print(R)


import math
(n, r) = map(int, input().split())
sin = math.sin(math.pi / n)
d = (r * sin) / (1 - sin)
print(d)


import math
n, r = map(int, input().split())
dk = math.sin(3.141592623587 / n)
print(r * dk / (1 - dk))


import math
n, r = map(int, input().split())
dk = math.sin(3.141592623587 / n)
print(dk)
print(r * dk / (1 - dk))


import math
n,r=map(int,input().split())
num=22*(n-2)
dem=14*n
#c=num/dem
#k=math.acos(c)
#ans=(r*k)/(1-k)
ans=(r*math.cos(num/dem))/(1-math.cos(num/dem))
print(ans)


import math
n,r=map(int,input().split())
num=math.pi*(n-2)
dem=2*n
#c=num/dem
#k=math.acos(c)
#ans=(r*k)/(1-k)
ans=(r*math.cos(num/dem))/(1-math.cos(num/dem))
print(ans)


import math

n,r = map(int,input().split())
angle = math.sin(math.pi/n)
print((r*angle)/(1-angle))


from math import *
n,r = map(int,input().split())
a = sin(pi/n)
b = sin(pi/2-pi/n)
print(r*a/(1-a))


n,m=map(int,input().split())
l1=list(map(int,input().split()))
ans=""
d1={}
d2={}
count=0
for item in l1:
    if item not in d1:
        d2[item]=1
        d1[item]=1
    else :
        if item in d2:
            del d2[item]
        d1[item]+=1
    if len(d1)==n:
        ans=ans+'1'
        for k in d2:
            del d1[k]
        for k in d1:
            d1[k]-=1
        d2={}
    else :
        ans=ans+'0'
print(ans)


import math
n,r=map(int,input().split())
ang=math.pi*(n-2)/(2*n)
print((r*math.cos(ang))/(1-math.cos(ang)))


import math
n,r=[int(x) for x in input().split()]
a=180*(n-2)/n
a=a/2
a=180/a
ang=math.cos(3.14159/a)
print((ang*r)/(1-ang))


import math
n,r=[int(x) for x in input().split()]
a=180*(n-2)/n
a=a/2
a=180/a
ang=math.cos(3.14/a)
print((ang*r)/(1-ang))


# -*- coding: utf-8 -*-
"""
Created on Fri Jun 28 15:07:55 2019

@author: plosi
"""
from math import cos,pi

def quad(a,b,c):

    return (-b+(b**2-4*a*c)**(0.5))/(2*a)

def main():
    n,r=input().split(" ")
    n=int(n)
    r=int(r)
    theta=2*pi/n
    a=4-2*(1-cos(theta))
    c=-2*r**2*(1-cos(theta))
    b=-4*r*(1-cos(theta))
    val=quad(a,b,c)
    print(val)
main()


import math

n, r = map(int, input().strip().split())

alpha = math.pi * (n - 2) / (2 * n)
beta = 2 * math.pi / n

t = math.tan((alpha - beta ) / 2) / math.tan((alpha + beta) / 2)

answer = (r - t * r) / (3 * t + 1)

print(answer)


import math
pi = math.pi
n,R = map(int,input().split())
print(R*math.sin(pi/n)/(1-math.sin(pi/n)))


import math
n = int(input())
r = int(input())

print(n)
print(r)
t = (2*math.pi)/n

res = math.sin(t/2)

ans = r*res
ans = ans/(1-res)

print(ans)


import math
s = input()
l = s.split(" ")

n = int(l[0])
r = int(l[1])

t = (2*math.pi)/n

res = math.sin(t/2)

ans = r*res
ans = ans/(1-res)

print(ans)


from math import sin, pi

n, r = map(int, input().split())

R = r*sin(pi/n)/(1-sin(pi/n))

print(R)


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[400000];
int sizee[400000];
bool vis[400000];
int parent[400000];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;
            return;
        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    parent[y]=-1;
    dfs(y);
    int s=x;
    while(parent[s]!=y)
    {
       s=parent[s];
    }
   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[400000];
int sizee[400000];
bool vis[400000];
int parent[400000];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;

        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    parent[y]=-1;
    dfs(y);
    int s=x;
    while(parent[s]!=y)
    {
       s=parent[s];
    }
   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[300005];
int sizee[300005];
bool vis[300005];
int parent[300005];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;

        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++)
        vis[i]=false;
    parent[y]=-1;
    dfs(y);
    int s=x;

    while(parent[s]!=y)
    {
       s=parent[s];
    }

   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[300005];
int sizee[300005];
bool vis[300005];
int parent[300005];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;

        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++)
        vis[i]=false;
    parent[y]=-1;
    dfs(y);
    int s=x;

    while(parent[s]!=y)
    {
       s=parent[s];
    }

   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[400000];
int sizee[400000];
bool vis[400000];
int parent[400000];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;
            return;
        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    parent[y]=-1;
    dfs(y);
    int s=x;
    while(parent[s]!=y)
    {

        s=parent[s];
    }
   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[300005];
int sizee[300005];
bool vis[300005];
int parent[300005];
void dfs(int s)
{
    vis[s]=true;
   sizee[s]=1;
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++)
        vis[i]=false;
    parent[y]=-1;
    dfs(y);
    int s=x;

    while(parent[s]!=y)
    {
       s=parent[s];
    }

   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;

    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[400000];
int sizee[400000];
bool vis[400000];
int parent[400000];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;

        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    parent[y]=-1;
    dfs(y);
    int s=x;
    if(n==3483)
        cout<<"done"<<endl;
    while(parent[s]!=y)
    {
       s=parent[s];
    }
    cout<<s<<endl;
   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
vector<int >adj[400000];
int sizee[400000];
bool vis[400000];
int parent[400000];
void dfs(int s)
{
    vis[s]=true;
    if(adj[s].size()==1)
        {
            sizee[s]=1;

        }
    for(int i=0;i<adj[s].size();i++)
    {
        if(vis[adj[s][i]]==false)
        {   parent[adj[s][i]]=s;
            dfs(adj[s][i]);
              sizee[s]+=sizee[adj[s][i]];
        }

    }
}

int main()
{
    ll n,x,y;
    cin>>x>>y>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    parent[y]=-1;
    dfs(y);
    int s=x;
    if(n==3483)
        cout<<"done"<<endl;
    while(parent[s]!=y)
    {
       s=parent[s];
    }
    if(n==3483)
    cout<<s<<endl;
   // cout<<sizee[y]<<sizee[x]<<sizee[s]<<s<<endl;
   ll ans=n*(n-1)-sizee[x]*(sizee[y]-sizee[s]);
   //cout<<s<<y<<endl;
   if(s==x)
    ans--;
    cout<<ans<<endl;

}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

int main(){
	long long int q;
	cin>>q;
	vector<long long int> arr;
	for (long long int i =0; i<q; i++){
		int t;
		cin>>t;
		if (t==1){
			long long int u;
			cin>>u;
			arr.push_back(u);
			// cout<<"pushed"<<endl;
		}
		else{
			long long int x,k,s, mx = LLONG_MIN, v = -1;;
			cin>>x>>k>>s;
			for (long long int j=0; j< arr.size(); j++){
				if(x+arr[j] <= s && (x ^ arr[j]) > mx){
					if (__gcd(x, arr[j]) % k == 0){
						mx = xr;
						v = arr[j];
					}
				}
			}
			cout<<v<<endl;
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

int main(){
	long long int q;
	cin>>q;
	vector<long long int> arr;
	for (long long int i =0; i<q; i++){
		int t;
		cin>>t;
		if (t==1){
			long long int u;
			cin>>u;
			arr.push_back(u);
			// cout<<"pushed"<<endl;
		}
		else{
			long long int x,k,s, mx = LLONG_MIN, v = -1;;
			cin>>x>>k>>s;
			for (long long int j=0; j< arr.size(); j++){
				if(x+arr[j] <= s){
					long long int xr = x ^ arr[j];
					if (xr > mx){
						if (__gcd(x, arr[j]) % k == 0){
							mx = xr;
							v = arr[j];
						}
					}
				}
			}
			cout<<v<<endl;
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<int> d(32767,0);
vector<int> finish(32767,0);
vector<int> color(32767,0);
vector<long long int> parent(32767,0);
long long int n,x,y;
int t = 0;

void DFS(const vector < vector<long long int> >& e, int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0)
		{
			parent[e[u][j]] = u;
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	long long int n,x,y;
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	long long int f_count = 1;
	long long int count = 0;
	long long int y_x = -1;
	d[x] = ++t;
	color[x] = 1;
	for (long long int j =0; j<e[x].size(); j++){
		if (color[e[x][j]] == 0)
			DFS(e, e[x][j]);
		if (color[y] > 0){
			y_x = e[x][j];
		}
	}
	color[x] = 2;
	finish[x] = ++t;

	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ( i != x && !(d[y_x] <= d[i] && d[i] <= finish[y_x])) {
			f_count++;
		}
	}
	// cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<int> d(32767,0);
vector<int> finish(32767,0);
vector<int> color(32767,0);
vector<long long int> parent(32767,0);
long long int n,x,y;
int t = 0;

void DFS(const vector < vector<long long int> >& e, int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0){
			parent[e[u][j]] = u;
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	long long int n,x,y;
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	DFS(e, x);
	long long int f_count = 1;
	long long int count = 0;
	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ((finish[i] < finish[y] && d[i] < d[y] && finish[i] < d[y]) ||
			(finish[i] > finish[y] && d[i] > d[y] && finish[y] < d[i])) {
			f_count++;
		}
	}
	// cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<long int> d(1000000,0);
vector<long int> finish(1000000,0);
vector<int> color(1000000,0);
long int n,x,y;
long int t = 0;

void DFS(const vector < vector<long long int> >& e, long long int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0)
		{
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	long long int f_count = 1;
	long long int count = 0;
	long long int y_x = -1;
	d[x] = ++t;
	color[x] = 1;
	for (long long int j =0; j<e[x].size(); j++){
		if (color[e[x][j]] == 0)
			DFS(e, e[x][j]);
		if (color[y] > 0 && y_x == -1){
			y_x = e[x][j];
		}
	}
	color[x] = 2;
	finish[x] = ++t;

	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ( i != x && !(d[y_x] <= d[i] &&
			 d[i] <= finish[y_x])) {
			f_count++;
		}
	}
	// cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<long int> d(1000000,0);
vector<long int> finish(1000000,0);
vector<int> color(1000000,0);
long int n,x,y;
long int t = 0;

void DFS(const vector < vector<long long int> >& e, long long int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0)
		{
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	long long int f_count = 1;
	long long int count = 0;
	long long int y_x = -1;
	d[x] = ++t;
	color[x] = 1;
	for (long long int j =0; j<e[x].size(); j++){
		if (color[e[x][j]] == 0)
			DFS(e, e[x][j]);
		if (color[y] > 0 && y_x == -1){
			y_x = e[x][j];
		}
	}
	color[x] = 2;
	finish[x] = ++t;

	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ( i != x && !(d[y_x] <= d[i] &&
			 d[i] <= finish[y_x])) {
			f_count++;
		}
	}
	cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<long int> d(1000000,0);
vector<long int> finish(1000000,0);
vector<int> color(1000000,0);
long long int n,x,y;
long int t = 0;

void DFS(const vector < vector<long long int> >& e, long long int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0)
		{
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	long long int f_count = 1;
	long long int count = 0;
	long long int y_x = -1;
	d[x] = ++t;
	color[x] = 1;
	for (long long int j =0; j<e[x].size(); j++){
		if (color[e[x][j]] == 0)
			DFS(e, e[x][j]);
		if (color[y] > 0 && y_x == -1){
			y_x = e[x][j];
		}
	}
	color[x] = 2;
	finish[x] = ++t;

	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ( i != x && !(d[y_x] <= d[i] &&
			 d[i] <= finish[y_x])) {
			f_count++;
		}
	}
	// cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>
#include <queue>
#include <map>

using namespace std;

vector<int> d(32767,0);
vector<int> finish(32767,0);
vector<int> color(32767,0);
vector<long long int> parent(32767,0);
long long int n,x,y;
int t = 0;

void DFS(const vector < vector<long long int> >& e, int u){
	t = t +1;
	d[u] = t;
	color[u] = 1;
	for (long long int j =0; j<e[u].size(); j++){
		if (color[e[u][j]] == 0)
		{
			parent[e[u][j]] = u;
			DFS(e, e[u][j]);
		}
	}
	color[u] = 2;
	t++;
	finish[u] = t;
}

int main(){
	long long int n,x,y;
	cin>>n>>x>>y;
	x--;y--;
	vector < vector<long long int> > e(n, vector<long long int>());
	for(long long int i =0; i<n-1; i++){
		long long int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	long long int f_count = 1;
	long long int count = 0;
	long long int y_x = -1;
	d[x] = ++t;
	color[x] = 1;
	for (long long int j =0; j<e[x].size(); j++){
		if (color[e[x][j]] == 0)
			DFS(e, e[x][j]);
		if (color[y] > 0 && y_x == -1){
			y_x = e[x][j];
		}
	}
	color[x] = 2;
	finish[x] = ++t;

	// for(long long int i =0; i<n; i++)
	// 	cout<<finish[i]<<" "<<d[i]<<endl;
	for(long long int i =0; i<n; i++){
		if (finish[i] <= finish[y] && d[i] >= d[y]){
			count++;
		}
	}
	for(long long int i =0; i<n; i++){
		if ( i != x && !(d[y_x] <= d[i] && d[i] <= finish[y_x])) {
			f_count++;
		}
	}
	// cout<<"before flower "<<f_count<<"  from bee "<<count<<endl;
	long long int res = n*(n-1) - count*f_count;
	cout<<res<<endl;
	return 0;
}


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

vector<ll>vt[300005];
ll vis[300005], cnt=0, n, y, x, a, b, dis=0;

void dfs(ll at, ll level){
    if(vis[at]) return ;
    vis[at]=1;
    cnt++;
    for(ll i=0; i<vt[at].size(); i++){
        ll u=vt[at][i];
        if(u!=y)dfs(vt[at][i], level+1);
        else dis=level;
    }
}

int main(){
    cin>>n>>x>>y;
    for(ll i=1; i<n; i++){
        cin>>a>>b;
        vt[a].push_back(b);
        vt[b].push_back(a);
    }
    for(ll i=0; i<=n; i++) vis[i]=0;
    dfs(x, 0);
    cout<<(n-1)*n-(cnt-dis)*(n-cnt)<<endl;
    return 0;
}


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

vector<ll>vt[300005];
ll vis[300005], cnt=0, n, y, x, a, b, dis;
// before calling, make vis[] all zero.
void dfs(ll at, ll level){
    if(vis[at]) return ; // if previously visited.
    vis[at]=1;
    cnt++;
    for(ll i=0; i<vt[at].size(); i++){
        ll u=vt[at][i];
        if(u!=y)dfs(vt[at][i], level+1);
        else dis=level;
    }
}

int main(){
    cin>>n>>x>>y;
    for(ll i=1; i<n; i++){
        cin>>a>>b;
        vt[a].push_back(b);
        vt[b].push_back(a);
    }
    for(ll i=0; i<=n; i++) vis[i]=0;
    dfs(x, 0);
    cout<<(n*2)-(cnt-dis)<<endl;
    return 0;
}


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

vector<ll>vt[300005];
ll vis[300005], cnt=0, n, y, x, a, b, dis=0;
// before calling, make vis[] all zero.
void dfs(ll at, ll level){
    if(vis[at]) return ; // if previously visited.
    vis[at]=1;
    cnt++;
    for(ll i=0; i<vt[at].size(); i++){
        ll u=vt[at][i];
        if(u!=y)dfs(vt[at][i], level+1);
        else dis=level;
    }
}

int main(){
    cin>>n>>x>>y;
    for(ll i=1; i<n; i++){
        cin>>a>>b;
        vt[a].push_back(b);
        vt[b].push_back(a);
    }
    for(ll i=0; i<=n; i++) vis[i]=0;
    dfs(x, 0);
    cout<<((n-1)*n)-(cnt-dis)<<endl;
    return 0;
}


        /*************************************
         **   Bismillahir Rahmanir Rahim    **
         **         Md. Al Mahfuz           **
         ** Islamic University, Bangladesh. **
         *************************************/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define fi(i, a, b) for(ll i=a; i<=b; i++)
#define fd(i, a, b) for(ll i=a; i>=b; i--)
#define clr(x, y)   memset(x, y, sizeof(x))
using namespace std;
vector<ll>vt[300005];

ll c=0, n, x, y, xx, yy, u, v, stop, cnt[300005]={0};

ll dfs(ll u, ll pre){
    ll ans=1;
    cnt[u]++;
    ll sz=vt[u].size(), v;
    fi(i, 0, sz-1){
        v=vt[u][i];
        if(v!=pre && v!=stop) ans+=dfs(v, u);
    }
    return ans;
}

int main(){
    cin>>n>>x>>y;
    fi(i, 1, n-1){
        cin>>u>>v;
        vt[u].pb(v);
        vt[v].pb(u);
    }
    stop=y;
    xx=dfs(x, -1);
    stop=x;
    yy=dfs(y, -1);
    fi(i, 1, n)
        if(cnt[i]==2) c++;
    cout<<n*(n-1)-(xx-c)*(yy-c)<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

vi adj[300009];
int level[300009], sub_t=1, fl=-1, P[300009][30], x, y, n;

void DFS(int u){
	int i, j;
	if(fl == 0)
		sub_t+=1;
	if(u == y)
		fl=0;
	for(i=0; i < adj[u].size(); i++){
        	if (P[adj[u][i]][0] == -1 && adj[u][i] != x){
            		P[adj[u][i]][0] = u;
            		level[adj[u][i]] = level[u] + 1;
           		DFS(adj[u][i]);
		}
	}
	if(u == y)
		fl=-1;
}

int lca(int u,int v1)
{
  int tmp,h,i;
  if(level[u]<level[v1]){
    tmp = u; u = v1; v1 = tmp;
  }
  for(h=1;(1<<h)<=n;h++);
  int diff=level[u]-level[v1];
  for(i=h-1; i>=0; i--)
    if( (diff>>i)&1 )
      u=P[u][i];
  if(u==v1)
    return u;
  for(i=h; i>=0; i--)
    if(P[u][i]!=P[v1][i])
      u=P[u][i],v1=P[v1][i];
  return P[u][0];
}

int main()
{
	int a, b, i, j;
	long long ans=0;
	cin>>n>>x>>y;
	for(i=1; i<=n-1; i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(level, -1, sizeof(level));
	memset(P, -1, sizeof(P));
	DFS(x);
	for(j=1; 1 << j < n; j++)
		for(i=1; i <= n; i++)
			if(P[i][j-1] != -1)
				P[i][j] = P[P[i][j-1]][j-1];
	for(i=1; i<=n; i++){
		if(lca(i,y) == x)
			ans += n-(sub_t)-1;
		else
			ans += n-1;
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

vi adj[300009];
int level[300009], sub_t=1, fl=-1, P[300009][30], x, y, n;

void DFS(int u){
	int i, j;
	if(fl == 0)
		sub_t+=1;
	if(u == y)
		fl=0;
	for(i=0; i < adj[u].size(); i++){
        	if (P[adj[u][i]][0] == -1 && adj[u][i] != x){
            		P[adj[u][i]][0] = u;
            		level[adj[u][i]] = level[u] + 1;
           		DFS(adj[u][i]);
		}
	}
	if(u == y)
		fl=-1;
}

int lca(int u,int v1)
{
  int tmp,h,i;
  if(level[u]<level[v1]){
    tmp = u; u = v1; v1 = tmp;
  }
  for(h=1;(1<<h)<=n;h++);
  int diff=level[u]-level[v1];
  for(i=h-1; i>=0; i--)
    if( (diff>>i)&1 )
      u=P[u][i];
  if(u==v1)
    return u;
  for(i=h; i>=0; i--)
    if(P[u][i]!=P[v1][i])
      u=P[u][i],v1=P[v1][i];
  return P[u][0];
}

int main()
{
	int a, b, i, j, ans=0;
	cin>>n>>x>>y;
	for(i=1; i<=n-1; i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(level, -1, sizeof(level));
	memset(P, -1, sizeof(P));
	DFS(x);
	for(j=1; 1 << j < n; j++)
		for(i=1; i <= n; i++)
			if(P[i][j-1] != -1)
				P[i][j] = P[P[i][j-1]][j-1];
	for(i=1; i<=n; i++){
		if(lca(i,y) == x)
			ans += n-(sub_t)-1;
		else
			ans += n-1;
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
vector<int>v[300005];
long long int vis1[300005]={0},vis2[300005]={0};

long long int a,b,c=0,n=0;
void dfs1(long long int x,long long int k)
{
    int i;
    c++;
    vis1[x]=1;
    vis1[k]=1;
    for(i=0;i<v[x].size();i++)
    {
       int d=v[x][i];
       if(vis1[d]==0)
       {
           dfs1(d,k);
       }
    }
}
void dfs2(long long int x,long long int k)
{
    long long int i;
    n++;
    vis2[x]=1;
    vis2[k]=1;
    for(i=0;i<v[x].size();i++)
    {
       long long int d=v[x][i];
       if(vis2[d]==0)
       {
           dfs2(d,k);
       }
    }
}
int main()
{
    long long int node,x,y;
    cin>>node>>a>>b;
    for(int i=0;i<node-1;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs1(a,b);
    dfs2(b,a);

   long long int ans=(node*(node-1))-((node-c)*(node-n));
   cout<<ans;
}
/*
9 2 3
1 2
1 6
6 7
6 8
2 3
2 9
3 4
3 5
*/


#include<bits/stdc++.h>
using namespace std;
vector<int>v[300005];
int vis[300005]={0};
int a,b,c=0,n=0;
int dfs(int x,int k)
{
    int i;
    vis[x]=1;
    for(i=0;i<v[x].size();i++)
    {
        int d=v[x][i];
      //  cout<<x<<" "<<d<<" "<<k<<endl;
       if(vis[d]==0)
       {
           if(x==a)
           {
               if(c>0)
               {
                   return n;
               }
               n=0;
           }
           n++;
           if(d==b)
           {
               k=1;
           }
           if(k==0)
           {
               dfs(d,0);
           }
           if(k>0)
           {
               c++;
               dfs(d,1);
           }
       }
    }
}
int main()
{
    int node,x,y;
    cin>>node>>a>>b;
    for(int i=0;i<node-1;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(a,0);
   long long int ans=(node*(node-1))-(c*(node-n));
   cout<<ans;
}
/*
9 2 3
1 2
1 6
6 7
6 8
2 3
2 9
3 4
3 5
*/


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

const int N = 3e5+1;
int vis[N] = {0}, nov = 0;
vector<int> adj[N];

int dfs(int v){
	vis[v]++;
	nov++;
	for(int i = 0; i < adj[v].size(); i++){
		if(vis[adj[v][i]] == 0)
			dfs(adj[v][i]);
	}
	return 0;
}
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	// vector<int> vis(n+1);
	long long yw = 1, xw = 1;
	vis[x] = 1;
	for(int i = 0; i < adj[x].size(); i++){
		dfs(adj[x][i]);
		if(vis[y])
			vis[y] = 0;
		else xw += nov;
		nov = 0;
	}
	for(int i = 0; i < n; i++){
		vis[i] = 0;
	}
	nov = 0;
	// int yw = 1;
	// for(int i = 0;)
	vis[y] = 1;
	for(int i = 0; i < adj[y].size(); i++){
		dfs(adj[y][i]);
		if(vis[x])
			vis[x] = 0;
		else yw += nov;
		nov = 0;
	}
	long long nll = n, ans;
	ans = nll*(nll-1) - xw*yw;
	cout << ans << endl;
	return 0;
}


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

const int N = 3e5+1;
int vis[N] = {0}, nov = 0;
vector<int> adj[N];

int dfs(int v){
	vis[v]++;
	nov++;
	for(int i = 0; i < adj[v].size(); i++){
		if(vis[adj[v][i]] == 0)
			dfs(adj[v][i]);
	}
	return 0;
}
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	// vector<int> vis(n+1);
	long long yw = 1, xw = 1;
	vis[x] = 1;
	for(int i = 0; i < adj[x].size(); i++){
		dfs(adj[x][i]);
		if(vis[y])
			vis[y] = 0;
		else xw += nov;
		nov = 0;
	}
	for(int i = 0; i <= n; i++){
		vis[i] = 0;
	}
	nov = 0;
	// int yw = 1;
	// for(int i = 0;)
	vis[y] = 1;
	for(int i = 0; i < adj[y].size(); i++){
		dfs(adj[y][i]);
		if(vis[x])
			vis[x] = 0;
		else yw += nov;
		nov = 0;
	}
	long long nll = n, ans;
	ans = nll*(nll-1) - xw*yw;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 3e5+10;

vector <int> ne[maxn];
bool vis[maxn];
int nep[maxn];

void dfs(int p,int q)
{
    int len = ne[p].size();
    vis[p] = true;
    for(int i=0;i<len;i++)
    {
        int nowpos = ne[p][i];
        if(vis[nowpos])
        {
            continue;
        }
        nep[nowpos] = p;
        if(nowpos == q)
        {
            return ;
        }
        dfs(nowpos,q);
    }
}

int main()
{
    int n,x,y;
    //freopen("in.txt","r",stdin);
    while(scanf("%d%d%d",&n,&x,&y)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            ne[i].clear();
        }
        memset(vis,false,sizeof vis);
        //memset(len,0,sizeof len);
        memset(nep,-1,sizeof nep);
        for(int i=1;i<n;i++)
        {
            int p,q;
            scanf("%d%d",&p,&q);
            ne[p].push_back(q);
            ne[q].push_back(p);
        }
        dfs(x,y);
        int nepy = nep[y];
        int nepx;
        for(nepx=y;nep[nepx]!=x;nepx=nep[nepx]);
        long long re = (long long)(n) * (long long)(n-1);
        long long xnum = 1;
        long long ynum = 1;
        int xlen = ne[x].size();
        int ylen = ne[y].size();
        for(int i=0;i<xlen;i++)
        {
            int nowpos = ne[x][i];
            if(nowpos == y || nowpos == nepx)
            {
                continue;
            }
            xnum++;
        }
        for(int i=0;i<ylen;i++)
        {
            int nowpos = ne[y][i];
            if(nowpos == x || nowpos == nepy)
            {
                continue;
            }
            ynum++;
        }
        re -= xnum * ynum;
        printf("%I64d\n",re);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>

using namespace std;

const int maxn = 3e5+10;

vector <int> ne[maxn];
bool vis[maxn];
int nep[maxn];

void dfs(int p,int q)
{
    int len = ne[p].size();
    vis[p] = true;
    for(int i=0;i<len;i++)
    {
        int nowpos = ne[p][i];
        if(vis[nowpos])
        {
            continue;
        }
        nep[nowpos] = p;
        if(nowpos == q)
        {
            return ;
        }
        dfs(nowpos,q);
    }
    return ;
}

void dfsnum(int k,long long &num)
{
    vis[k] = true;
    int len = ne[k].size();
    for(int i=0;i<len;i++)
    {
        int nowpos = ne[k][i];
        if(vis[nowpos])
        {
            continue;
        }
        num++;
        dfsnum(nowpos,num);
    }
    return ;
}

int main()
{
    int n,x,y;
    //freopen("in.txt","r",stdin);
    while(scanf("%d%d%d",&n,&x,&y)!=EOF)
    {
        for(int i=1;i<=n;i++)
        {
            ne[i].clear();
        }
        memset(vis,false,sizeof vis);
        //memset(len,0,sizeof len);
        memset(nep,-1,sizeof nep);
        for(int i=1;i<n;i++)
        {
            int p,q;
            scanf("%d%d",&p,&q);
            ne[p].push_back(q);
            ne[q].push_back(p);
        }
        if(n==1)
        {
            printf("0\n");
        }
        else
        {
            dfs(x,y);
            int nepy = nep[y];
            int nepx;
            for(nepx=y;nep[nepx]!=x;nepx=nep[nepx]);
            long long re = (long long)(n) * (long long)(n-1);
            long long xnum = 1;
            long long ynum = 1;
            int xlen = ne[x].size();
            int ylen = ne[y].size();
            memset(vis,false,sizeof vis);
            for(int i=0;i<xlen;i++)
            {
                int nowpos = ne[x][i];
                if(nowpos == y || nowpos == nepx)
                {
                    continue;
                }
                xnum++;
                vis[x] = true;
                dfsnum(nowpos,xnum);
            }
            for(int i=0;i<ylen;i++)
            {
                int nowpos = ne[y][i];
                if(nowpos == x || nowpos == nepy)
                {
                    continue;
                }
                ynum++;
                vis[y] = true;
                dfsnum(nowpos,ynum);
            }
            re -= xnum * ynum;
            printf("%I64d\n",re);
            //cout << xnum << "*" << ynum << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,y;
vector< vector<long int> > v(300001);
vector<long int> child(300001,0);
void dfs(long int s,long int src)
{
//	cout<<s<<"y\n";
	child[s]=1;
	vector<long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<long int> q;
	q.push(x);
	bool visi[n+1]={false};
	visi[x]=true;
	bool f=0;
	long int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		long int t=q.front();
		q.pop();
		vector<long int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
//	cout<<"start "<<start<<"\n";
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	long int ans=n*(n-1)-child[x]*child[y];
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,y;
vector< vector<long int> > v(300001);
vector<long int> child(300001,0);
void dfs(long int s,long int src)
{
	child[s]=1;
	vector<long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	dfs(x,-1);
	int a=child[y];
	dfs(y,-1);
	int b=child[x];
	long int ans=n*(n-1)-(a*b);
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,y;
vector< vector<long int> > v(300001);
vector<long int> child(300001,0);
void dfs(long int s,long int src)
{
//	cout<<s<<"y\n";
	child[s]=1;
	vector<long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<long int> q;
	q.push(x);
	bool visi[n+1]={false};
	visi[x]=true;
	bool f=0;
	long int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		long int t=q.front();
		q.pop();
		vector<long int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
//	cout<<"start "<<start<<"\n";
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	cout<<n*(n-1)-child[x]*child[y];
}


#include <bits/stdc++.h>
using namespace std;
long long int n,x,y;
vector< vector<long long int> > v(300001);
vector<long long int> child(300001,0);
void dfs(long long int s,long long int src)
{
	child[s]=1;
	vector<long long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	dfs(x,-1);
	long long int a=child[y];
	dfs(y,-1);
	long long int b=child[x];
	long long int ans=n*(n-1)-(a*b);
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
int n,x,y;
vector< vector<int> > v(300001);
vector<int> child(300001,0);
void dfs(int s,int src)
{
//	cout<<s<<"y\n";
	child[s]=1;
	vector<int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<int> q;
	q.push(x);
	bool visi[n+1]={false};
	visi[x]=true;
	bool f=0;
	int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		int t=q.front();
		q.pop();
		vector<int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
//	cout<<"start "<<start<<"\n";
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	cout<<n*(n-1)-child[x]*child[y];
}


#include <bits/stdc++.h>
using namespace std;
long int n,x,y;
vector< vector<long int> > v(300001);
vector<long int> child(300001,0);
void dfs(long int s,long int src)
{
	child[s]=1;
	vector<long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<long int> q;
	q.push(x);
	vector<bool> visi(300001,false);
	visi[x]=true;
	bool f=0;
	long int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		long int t=q.front();
		q.pop();
		vector<long int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	long int ans=n*(n-1)-(child[x]*child[y]);
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
long long int n,x,y;
vector< vector<long long int> > v(300001);
vector<long long int> child(300001,0);
void dfs(long long int s,long long int src)
{
	child[s]=1;
	vector<long long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<long long int> q;
	q.push(x);
	vector<bool> visi(300001,false);
	visi[x]=true;
	bool f=0;
	long long int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		long int t=q.front();
		q.pop();
		vector<long int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	long long int ans=n*(n-1)-(child[x]*child[y];
	cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
long long int n,x,y;
vector< vector<long long int> > v(300001);
vector<long long int> child(300001,0);
void dfs(long long int s,long long int src)
{
	child[s]=1;
	vector<long long int>::iterator itr;
	for(itr=v[s].begin();itr!=v[s].end();itr++)
	{
		if(*itr!=src)
		{
			dfs(*itr,s);
			child[s]+=child[*itr];
		}
	}
}
int main()
{
	cin>>n>>x>>y;
	long long int i,j,k;
	for(i=1;i<=n-1;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		v[k].push_back(j);
	}
	queue<long long int> q;
	q.push(x);
	vector<bool> visi(300001,false);
	visi[x]=true;
	bool f=0;
	long long int start;
	bool g=0;
	while(!q.empty())
	{
//		cout<<"x";
		long int t=q.front();
		q.pop();
		vector<long long int>::iterator itr;
		for(itr=v[t].begin();itr!=v[t].end();itr++)
		{
			if(!visi[*itr])
			{
				if(*itr==y)
				{
					start=t;
					f=1;
					if(t==x)
						g=1;
					break;
				}
				else
				{
					q.push(*itr);
					visi[*itr]=true;
				}
			}
		}
		if(f)
			break;
	}
	dfs(start,-1);
	if(g)
	{
		child[x]-=child[y];
	}
	long long int ans=n*(n-1)-(child[x]*child[y]);
	cout<<ans;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   lli temp;
   dfs(graph,subSize,isThere,x,-1,y);
   for(int i=0;i<graph[x].size();i++)
   {
       if(isThere[graph[x][i]]){
           temp=subSize[x]-subSize[graph[x][i]];
          break;
       }
   }
   total=total-(subSize[y]*temp);
   printf("%I64d", 1LL * n * (n - 1) - temp * subSize[y]);
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,int subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   int subSize[n],isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   uli total=n*(n-1);
   dfs(graph,subSize,isThere,x,-1,y);
   uli sum=0;
   for(int i=0;i<graph[x].size();i++)
   {
       if(!isThere[graph[x][i]])
          sum+=subSize[graph[x][i]];
   }
   sum+=1;
   cout<<total-(sum*subSize[y])<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   dfs(graph,subSize,isThere,x,-1,y);
   lli sum=0;
   for(int i=0;i<graph[x].size();i++)
   {
       if(!isThere[graph[x][i]])
          sum+=subSize[graph[x][i]];
   }
   sum+=1;
   sum=(sum*subSize[y]);
   cout<<total-sum<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,int subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   int subSize[n],isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   uli total=n*(n-1);
   dfs(graph,subSize,isThere,x,-1,y);
   uli sum=0;
   for(int i=0;i<graph[x].size();i++)
   {
       if(!isThere[graph[x][i]])
          sum+=subSize[graph[x][i]];
   }
   sum+=1;
   cout<<total-sum<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   lli temp;
   dfs(graph,subSize,isThere,y,-1,x);
   for(int i=0;i<graph[y].size();i++)
   {
       if(isThere[graph[y][i]]){
           temp=subSize[y]-subSize[graph[y][i]];
          break;
       }
   }
   total=total-(subSize[x]*temp);
   cout<<total<<endl;
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<stdio.h>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   lli temp;
   dfs(graph,subSize,isThere,y,-1,x);
   for(int i=0;i<graph[y].size();i++)
   {
       if(isThere[graph[y][i]]){
           temp=subSize[y]-subSize[graph[y][i]];
          break;
       }
   }
   total=total-(subSize[x]*temp);
   printf("%I64d", 1LL * n * (n - 1) - temp * subSize[x]);
   return 0;
}


                             /*THIS CODE IS THE
                                     PROPERTY OF
                               THE HALF-BLOOD PRINCE*/
#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
#include<algorithm>
#include<unordered_map>
#include<stack>
#define minm(a,b) (a>b?b:a)
using namespace std;
typedef long long int lli;
typedef unsigned long long int uli;

void dfs(vector<vector<int>>& graph,lli subSize[],int isThere[],int node,int prev,int y)
{
    subSize[node]=1;
    if(node==y)
     isThere[node]=1;
    for(int i=0;i<graph[node].size();i++)
    {

        if(graph[node][i]!=prev)
        {
            dfs(graph,subSize,isThere,graph[node][i],node,y);
            subSize[node]+=subSize[graph[node][i]];
            isThere[node]+=isThere[graph[node][i]];
        }
    }
}

int main()
{
   int n,x,y;
   cin>>n>>x>>y;
   x--;
   y--;
   vector<vector<int>>graph(n);
   for(int i=0;i<n-1;i++)
   {
       int u,v;
       cin>>u>>v;
       u--;
       v--;
       graph[u].push_back(v);
       graph[v].push_back(u);
   }
   lli subSize[n];
   int isThere[n];
   for(int i=0;i<n;i++)
    subSize[i]=isThere[i]=0;
   lli total=n*(n-1);
   dfs(graph,subSize,isThere,y,-1,x);
   for(int i=0;i<graph[y].size();i++)
   {
       if(isThere[graph[y][i]]){
          lli temp=subSize[y]-subSize[graph[y][i]];
          break;
       }
   }
   total=total-(subSize[x]*temp);
   cout<<total<<endl;
   return 0;
}