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

#define ABS(x) ((x)<0 ? -(x) : (x))
#define REP(i,n) for(int i=0, _e(n); i<_e; i++)
#define SET(t,v) memset((t), (v), sizeof(t))
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )

#define inf_int (1<<31)-1
#define inf_long (1<<63)-1
#define sz size()
#define pb push_back
#define VI vector<int>
#define VS vector<string>

typedef long double LD;
typedef pair<int,int> pii;

#ifdef DEBUG
#define dbg(x) x
#define dbgp(x) cerr << x ;
#else
#define dbg(x) //x
#define dbgp(x) //cerr << x << endl;
#endif

int n ;
int a[2*100001];

int main(){
    cin >> n ;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    sort(a,a+n+1);
    map<long long,long long> m ;
    for(int i=1;i<=n;i++){
        m[a[i]-a[i-1]]++;
    }
    map<long long,long long>::iterator it = m.begin() ;
    ++it;
    cout << it->first << " " << it->second << endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
using namespace std;

map<long long,long long>mp;

int main()
{
    long long n,ans=0;
    cin>>n;
    priority_queue<long long>pq;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
        mp[a[i]]++;

    }
    long long mn = 1e18;
    while(pq.size() >= 2)
    {
         long long l = pq.top();
         pq.pop();
         mn = min(mn,(long long)l - pq.top());
    }
    for(int i=0;i<n;i++)
    {
        ans+=mp[abs(a[i] - mn)];
        mp[abs(a[i] - mn)] = 0;
    }
    cout<<mn<<" "<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
using namespace std;

map<long long,long long>mp;

int main()
{
    long long n,ans=0;
    cin>>n;
    priority_queue<long long>pq;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
        mp[a[i]]++;

    }
    long long mn = 1e18;
    while(!pq.empty())
    {
         long long l = pq.top();
         pq.pop();
         if(pq.size() == 0)
            break;
         long long d = pq.top();
         mn = min(mn,abs((long long)l - pq.top()));
    }
    for(int i=0;i<n;i++)
    {
        ans+=mp[abs(a[i] - mn)];
        mp[abs(a[i] - mn)] = 0;
    }
    cout<<mn<<" "<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
using namespace std;

map<int,int>mp;

int main()
{
    int n,ans=0;
    cin>>n;
    priority_queue<int>pq;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
        mp[a[i]]++;

    }
    long long mn = 1e18;
    while(pq.size() >= 2)
    {
         int l = pq.top();
         pq.pop();
         mn = min(mn,(long long)l - pq.top());
    }
    for(int i=0;i<n;i++)
    {
        ans+=mp[abs(a[i] - mn)];
        mp[abs(a[i] - mn)] = 0;
    }
    cout<<mn<<" "<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
using namespace std;

map<long long,long long>mp;

int main()
{
    long long n,ans=0;
    cin>>n;
    priority_queue<long long>pq;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
        mp[a[i]]++;

    }
    long long mn = 1e18;
    while(!pq.empty())
    {
         long long l = pq.top();
         pq.pop();
         if(pq.size() == 0)
            break;
         long long d = pq.top();
         mn = min(mn,(long long)l - pq.top());
    }
    for(int i=0;i<n;i++)
    {
        ans+=mp[a[i]-mn];
        mp[a[i]-mn] = 0;
    }
    cout<<mn<<" "<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<map>
#include<queue>
#include<iterator>
using namespace std;

map<long long,long long>mp;

int main()
{
    long long n,ans=0;
    cin>>n;
    priority_queue<long long>pq;
    long long a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        pq.push(a[i]);
        mp[a[i]]++;

    }
    long long mn = 1e18;
    while(!pq.empty())
    {
         long long l = pq.top();
         pq.pop();
         if(pq.size() == 0)
            break;
         long long d = pq.top();
         mn = min(mn,(long long)l - pq.top());
    }
    for(int i=0;i<n;i++)
    {
        ans+=mp[mn-a[i]];
        ans+=mp[a[i]-mn];
        mp[mn-a[i]] = 0;
        mp[a[i]-mn] = 0;
    }
    cout<<mn<<" "<<ans<<endl;
    return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	sort(position.begin(),position.end());
	long long result = 1;
	long long minDist = numeric_limits<int>::max();
	for(int i=1;i<cnt;i++){
		int dist = position[i]-position[i-1];
		if(minDist==dist){
			result++;
		}else{
			result=1;
			minDist=dist;
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	long long position[200005];
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>position[i];
	}

	long long result = 1;
	long long minDist = numeric_limits<int>::max();
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			int dist = abs(position[i]-position[j]);
			if(minDist == dist){
				result++;
			}else if(dist < minDist){
				result = 1;
				minDist = dist;
			}
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	long long position[200005];
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>position[i];
	}

	long long result = 0;
	long long minDist = numeric_limits<int>::max();
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			int dist = abs(position[i]-position[j]);
			if(minDist == dist){
				result++;
			}else if(dist < minDist){
				result=0;
			}
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	sort(position.begin(),position.end());
	long long result = 1;
	long long minDist = abs(position[cnt-1]-position[0]);
	for(int i=1;i<cnt;i++){
		int dist = abs(position[i]-position[i-1]);
		if(minDist==dist){
			result++;
		}else{
			result=1;
			minDist=dist;
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	sort(position.begin(),position.end());
	long long result = 1;
	long long minDist = abs(position[cnt-1]-position[0]);
	for(int i=1;i<cnt&&cnt>2;i++){
		int dist = abs(position[i]-position[i-1]);
		if(minDist==dist){
			result++;
		}else{
			result=1;
			minDist=dist;
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	sort(position.begin(),position.end());
	long long result = 1;
	long long minDist = abs(position[cnt-1]-position[0]);
	for(int i=1;i<cnt&&cnt>2;i++){
		int dist = abs(position[i]-position[i-1]);
		if(minDist==dist){
			result++;
		}else if(dist<minDist){
			result=1;
			minDist=dist;
		}
	}
	cout << minDist << " " << result << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	unordered_map<long long, long long> mp;
	long long result = 0;
	long long minDist = numeric_limits<int>::max();
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			int dist = abs(position[i]-position[j]);
			minDist = minDist<dist?minDist:dist;
			result += (mp[dist]++);
		}
	}
	cout << mp[minDist] << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	long long position[200005];
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>position[i];
	}

	unordered_map<long long, long long> mp;
	long long result = 0;
	long long minDist = numeric_limits<int>::max();
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			int dist = abs(position[i]-position[j]);
			minDist = minDist<dist?minDist:dist;
			result += (mp[dist]++);
		}
	}
	cout << minDist << " " << mp[minDist] << endl;
	return 0;
}


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

int main(){
	int cnt = 0;
	cin >> cnt;

	vector<long long>position;
	long long tmp =0;
	for(int i=0;i<cnt;i++){
		cin>>tmp;
		position.push_back(tmp);
	}

	unordered_map<long long, long long> mp;
	long long result = 0;
	long long minDist = numeric_limits<int>::max();
	for(int i=0;i<cnt;i++){
		for(int j=i+1;j<cnt;j++){
			int dist = abs(position[i]-position[j]);
			minDist = minDist<dist?minDist:dist;
			result += (mp[dist]++);
		}
	}
	cout << minDist << " " << mp[minDist] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100000],s;
int main()
{
//freopen("data.inp","r",stdin);
 // freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];

        sort(a+1,a+n+1);
        int gtnn=100000000;

 for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1)
      {

     if (abs(a[i]-a[p])<gtnn) gtnn=abs(a[i]-a[p]);
      }
 }
    int d=0;
    for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1)
      {
            if (abs(a[i]-a[p])==gtnn) d++;
      }
 }
 cout<<gtnn<<" "<<d;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,d,a[100000],ss,r;

int main()
{
//freopen("data.inp","r",stdin);
//freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];
    r=100000000000;
        sort(a+1,a+n+1);
     for (int i=1;i<n;i++)
        r=min(r,abs(a[i]-a[i+1]));
    ss=0;d=1;
    if (r==0)
    {
        for (int i=1;i<n+1;i++)
        if (a[i]==a[i+1])
        d++;
        else{
            ss=ss+(d*(d-1))/2;
            d=1;
        }
        ss=ss+(d*(d-1))/2;
        cout<<"0 "<<ss;
    }
    else
    {
            d=0;
        for (int i=1;i<n;i++)
            if (abs(a[i]-a[i+1])==r) d++;

    cout<<r<<" "<<d;
    }

}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100000],s;
int main()
{
   // freopen("data.inp","r",stdin);
  // freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];

        sort(a+1,a+n+1);
        int gtnn=100000000;

 for (int i=1;i<n+1;i++)
 {
    int  p=upper_bound(a+1,a+n+1,a[i]) -a;
      if (p!=n+1)
      {

     if (abs(a[i]-a[p])<gtnn) gtnn=abs(a[i]-a[p]);
      }
 }
    int d=0;
    for (int i=1;i<n+1;i++)
 {
    int  p=upper_bound(a+1,a+n+1,a[i]) -a;
      if (p!=n+1)
      {
            if (abs(a[i]-a[p])==gtnn) d++;
      }
 }
 cout<<gtnn<<" "<<d;
}


#include<bits/stdc++.h>
using namespace std;
int n,d,a[100000],s;
int main()
{
//freopen("data.inp","r",stdin);
 //freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];

        sort(a+1,a+n+1);
        int gtnn=100000000;

 for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1&&i<p)
      {

     if (abs(a[i]-a[p])<gtnn) gtnn=abs(a[i]-a[p]);
      }
 }
    int d=0;
    for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1&&i<p)
      {
            if (abs(a[i]-a[p])==gtnn) d++;
      }
 }
 cout<<gtnn<<" "<<d;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,d,a[100000],ss,r;

int main()
{
//reopen("data.inp","r",stdin);
 //freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];
    r=100000000000;
        sort(a+1,a+n+1);
     for (int i=1;i<n;i++)
        r=min(r,abs(a[i]-a[i+1]));
        d=1;ss=0;
    if (r==0)
    {
        for (int i=1;i<n+1;i++)
        if (a[i]==a[i+1])
        d++;
        else{
            ss=ss+(d*(d-1))/2;
            d=1;
        }
        ss=ss+(d*(d-1))/2;
        cout<<"0 "<<ss;
    }
    else
    {
        for (int i=1;i<n;i++)
            if (abs(a[i]-a[i+1])==r) d++;

    cout<<r<<" "<<d-1;
    }

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,d,a[100000],s;
bool kt[10000][10000];

int main()
{
//freopen("data.inp","r",stdin);
 //freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];

        sort(a+1,a+n+1);
        ll gtnn=10000000000,dem=1,ss=0;

    for (int i=1;i<n;i++)
        if (a[i]==a[i+1])
                dem++;
                else{
                    ss=ss+(dem*(dem-1))/2;
                    dem=1;
                }
                if (dem>1&&ss==0) ss=(dem*(dem-1))/2;
    if  (ss!=0) {
        cout<<"0 "<<ss;
        return 0;
    }
    else{
 for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1&&i<p)
      {

     if (abs(a[i]-a[p])<gtnn) gtnn=abs(a[i]-a[p]);
      }
 }
    int d=0;

    for (int i=1;i<n+1;i++)
 {
    int  p=lower_bound(a+1,a+n+1,a[i]) -a;
    p=p+1;
      if (p!=n+1&&i<p)
      {

            if (abs(a[i]-a[p])==gtnn) d++;
      }
 }
 cout<<gtnn<<" "<<d<<endl;
    }

}


#include<bits/stdc++.h>
using namespace std;
int n,d[1000000],a[100000],s;
int main()
{
   // freopen("data.inp","r",stdin);
   // freopen("data.out","w",stdout);
    cin>>n;
    for (int i=1;i<n+1;i++)
        cin>>a[i];

        sort(a+1,a+n+1);
        int gtnn=100000000;

            memset(d,0,sizeof(d));

 for (int i=1;i<n+1;i++)
 {
    int  p=upper_bound(a+1,a+n+1,a[i]) -a;
      if (p!=n+1)
      {

     d[abs(a[i]-a[p])]++;

     if (abs(a[i]-a[p])<gtnn) gtnn=abs(a[i]-a[p]);
      }
 }

 cout<<gtnn<<" "<<d[gtnn];
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a=0,d=0,n,c;
                      scanf("%s",&s);
                      c=strlen(s);
                      for(i=0;i<c;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a=0,d=0,n,c;
                      scanf("%d",&n);
                      for(i=0;i<n;i++)
                      {
                                            scanf("%s",&s[i]);
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }
                      }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a,c=0,d,n;
                      scanf("%s",&s);
                      a=strlen(s);
                      for(i=0;i<a;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  c++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }

                      }
                      if(c>d)
                      {
                                            printf("Andon");
                      }
                      else if(c<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a,d,n;
                      scanf("%s",&s);
                      a=strlen(s);
                      for(i=0;i<a;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            if(s[i]=='D')
                                            {
                                                                  d++;
                                            }

                      }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[1000000];
                      int i,c=0,d=0,n,a;
                      scanf("%s",&s);
                      a=strlen(s);
                      for(i=0;i<a;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  c++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }

                      }

                      if(c>d)
                      {
                                            printf("\nAnton");
                      }
                      else if(c<d)
                      {
                                            printf("\nDanik");

                      }
                      else{
                                            printf("\nFriendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a=0,d=0,n;
                      scanf("%s",&s);
                      a=strlen(s);
                      for(i=0;i<a;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }

                      }
                      if(a>d)
                      {
                                            printf("Andon");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[100000];
                      int i,a=0,d=0,n,c;
                      scanf("%d",&n);
                      c=strlen(s);
                      for(i=0;i<c;i++)
                      {
                                            scanf("%s",&s[i]);
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }
                      }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,a=0,d=0,n,c;
                      scanf("%s",&s);
                      c=strlen(s);
                      for(i=0;i<c;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }
                      }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else if(a==d)
                      {
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
                      char s[10000];
                      int i,a=0,d=0,n,c;
                      scanf("%s",&s);
                      c=strlen(s);
                      for(i=0;i<c;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  a++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }
                      }
                      if(a>d)
                      {
                                            printf("Anton");
                      }
                      else if(a<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include<stdio.h>
int main()
{
                      char s[10000];
                      int i,c=0,d=0,n,a;
                      scanf("%s",&s);
                      a=strlen(s);
                      for(i=0;i<a;i++)
                      {
                                            if(s[i]=='A')
                                            {
                                                                  c++;
                                            }
                                            else
                                            {
                                                                  d++;
                                            }

                      }

                      if(c>d)
                      {
                                            printf("\nAnton");
                      }
                      else if(c<d)
                      {
                                            printf("Danik");

                      }
                      else{
                                            printf("Friendship");
                      }

                      return 0;
}


#include <stdio.h>

int main(void)
{
       int n;
       char c;
       int A = 0;
       int D = 0;

       scanf("%i", &n);

       for (int i = 0; i < n; i++)
       {
              scanf(" %c", &c);

              if (c == 'A')
              {
                     A++;
              }
              else if (c == 'D')
              {
                     D++;
              }
       }

       if (A > D)
       {
              printf("Anton");
       }
       else if (A < D)
       {
              printf("Danik");
       }
       else
       {
              printf("Friendship");
       }

}


#include <stdio.h>

int main(void)
{
       int n;
       char c;
       int A = 0, D = 0;

       scanf("%i", &n);

       for (int i = 0; i < n; i++)
       {
              scanf("%c", &c);

              if (c == 'A')
              {
                     A++;
              }
              else if (c == 'D')
              {
                     D++;
              }
       }

       if (A > D)
       {
              printf("Anton");
       }
       else if (D > A)
       {
              printf("Danik");
       }
       else if (A == D)
       {
              printf("Friendship");
       }

}


#include <stdio.h>

int main(void)
{
       int n;
       char c;
       int A = 0, D = 0;

       scanf("%i", &n);

       for (int i = 0; i < n; i++)
       {
              scanf("%c", &c);

              if (c == 'A')
              {
                     A++;
              }
              else if (c == 'D')
              {
                     D++;
              }
       }

       if (A > D)
       {
              printf("Anton");
       }
       else if (A < D)
       {
              printf("Danik");
       }
       else
       {
              printf("Friendship");
       }

}


#include <stdio.h>

int main(void)
{
       int n;
       char c;
       int A = 0, D = 0;

       scanf("%i", &n);

       for (int i = 0; i < n; i++)
       {
              scanf(" %c", &c);

              if (c == 'A')
              {
                     A++;
              }
              else if (c == 'D')
              {
                     D++;
              }
       }

       if (A > D)
       {
              printf("Anton");
       }
       else if (A < D)
       {
              printf("Danik");
       }
       else
       {
              printf("Friendship");
       }

}


#include <stdio.h>

int main(void)
{
       int n;
       char c;
       int A, D;

       scanf("%i", &n);

       for (int i = 0; i < n; i++)
       {
              scanf("%c", &c);

              if (c == 'A')
              {
                     A++;
              }
              else if (c == 'D')
              {
                     D++;
              }
       }

       if (A > D)
       {
              printf("Anton");
       }
       else if (A < D)
       {
              printf("Danik");
       }
       else
       {
              printf("Friendship");
       }

}


#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    int A=0,D=0;
    for(int i=0;i<n;i++){
        if(a[i]=='A')A++;
        if(a[i]=='D')D++;
    }
    if(A>D)printf("Anton");
    if(A<D)printf("Danik");
    if(A==D)printf("frindship");
}


#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char a[n];
    scanf("%s",&a);
    int A=0,D=0;
    for(int i=0;i<n;i++){
        if(a[i]=='A')A++;
        if(a[i]=='D')D++;
    }
    if(A>D)printf("Anton");
    if(A<D)printf("Danik");
    if(A==D)printf("frindship");
}


#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    int A=0,D=0;
    for(int i=0;i<n;i++){
        if(a[i]=='A')A++;
        if(a[i]=='D')D++;
    }
    if(A>D)printf("Anton");
    if(A<D)printf("Danik");
    if(A==D)printf("frindship");
    return 0;
}


 #include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    int A=0,D=0;
    for(int i=0;i<n;i++){
        if(a[i]=='A')A++;
        if(a[i]=='D')D++;
    }
    if(A>D)printf("Anton");
    if(A<D)printf("Danik");
    if(A==D)printf("Friendship");
    return 0;
}


#include <stdio.h>

int main(){

int n=100000, Z,w,i;

char a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else
w=w+1;}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z,w,i;

char* a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else
w=w+1;}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n , Z=0,w=0,i;

char a[100000];
scanf("%d",&n);

scanf("%s",&a);

for (i=0;i<n;i++)
{if (a[i]=='A')
{Z=Z+1;}
else if(a[i]=='D')
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
else if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z,w,i;

char a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else if(a[i]=="D")
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n , Z=0,w=0,i;

char a[100000];
scanf("%d",&n);

scanf("%s",&a);

for (i=0;i<n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else if(a[i]=="D")
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z=0,w=0,i;

char a[100000];

scanf("%s",&a);

for (i=0;i<n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else if(a[i]=="D")
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z,w;

char* a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A";)
{Z=Z+1;}
else if(a[i]=="D")
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>
#include <stdlib.h>

int main(){

int n , Z=0,w=0,i;

char a[100000];
scanf("%d",&n);

scanf("%s",&a);

for (i=0;i<n;i++)
{if (a[i]=='A')
{Z=Z+1;}
else if(a[i]=='D')
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>
#include <stdlib.h>

int main(){

int n , Z=0,w=0,i;

char a[100000];
scanf("%d",&n);

scanf("%s",&a);

for (i=0;a[i]!='\0';i++)
{if (a[i]=='A')
{Z=Z+1;}
else if(a[i]=='D')
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
else if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>
#include <stdlib.h>

int main(){

int n , Z=0,w=0,i;

char a[100000];
scanf("%d",&n);

scanf("%s",&a);

for (i=0;i<n;i++)
{if (a[i]=='A')
{Z=Z+1;}
else if(a[i]=='D')
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
else if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z,w;

char a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A";)
{Z=Z+1;}
else
w=w+1;}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include <stdio.h>

int main(){

int n=100000, Z=0,w=0,i;

char a[100000];

scanf("%s",&a);

for (i=1;i<=n;i++)
{if (a[i]=="A")
{Z=Z+1;}
else if(a[i]=="D")
{w=w+1;}
}

if (Z>w)
{printf("Anton");}
if(w>Z)
{printf("Danik");}
else
{printf("Friendship");}

}


#include<stdio.h>
int main()
{
    int n,a,d,i;
    scanf("%d",&n);
    char a[n];
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        if(a[i]=='A')
        a++;
        else
        d++;
    }
    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danin");
    else
    printf("Friendship");
}


#include<stdio.h>
int main()
{
    int n,a,d,i;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",arr);
    for(i=0;i<n;i++)
    {
        if(arr[i]=='A')
        a++;
        else
        d++;
    }
    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danin");
    else
    printf("Friendship");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    scanf("\n%s",str);
    for(i=0;i<n+2;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=='D')
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
int main()
{
    int n,i,antonc=0,danikc=0;
    scanf("%d",&n);
    char str[n];
    for(i=0;i<n;i++)
    {
        scanf("%c",&str[i]);
        if(str[i]=="A")
        anton++;
        else if(str[i]=='D')
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    for(i=0;i<n;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=='D')
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    for(i=0;i<n;i++)
    {
        scanf("%c",&str[i]);
        if(str[i]=="A")
        anton++;
        else if(str[i]=='D')
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    for(i=0;i<n+2;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=="D")
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    scanf("%s",str);
    for(i=0;i<n;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=="D")
        danik++;
    }
    printf("%d %d\n",anton,danik);
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    gets(str);
    for(i=0;i<n;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=='D')
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
int main()
{
    int n,a,d,i;
    scanf("%d",&n);
    char arr[n];
    scanf("%s",arr);
    for(i=0;i<n;i++)
    {
        if(arr[i]=='A')
        a++;
        else
        d++;
    }
    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danik");
    else
    printf("Friendship");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,anton=0,danik=0;
    scanf("%d",&n);
    char str[n];
    gets(str);
    for(i=0;i<n;i++)
    {
        if(str[i]=="A")
        anton++;
        else if(str[i]=="D")
        danik++;
    }
    if(anton==danik)
    printf("Friendship");
    else if(anton>danik)
    printf("Anton");
    else if(danik>anton)
    printf("Danik");
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[n+1];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");
		return 0;
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[100000];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Anton");
    else if(na<nd)
    printf("Danik");
    else
    printf("Friendship");
		return 0;
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[n-1];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");
		return 0;
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[100000];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");
		return 0;
}


#include<stdio.h>
int main()
{
	char c;
	int na,nd,n,i;

	scanf("%d",&n);
	na=0;
	nd=0;
	for(i=1;i<=n;i++)
	{
	scanf(" %c",&c);
	if (c=='A')
	na=na+1;
	else if (c=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");

		return 0;
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[n];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");
		return 0;
}


#include<stdio.h>
int main()
{int na,nd,n,i;
	char S[100];

scanf("%d",&n);
scanf("%s" ,S);
	na=0;
	nd=0;
	for(i=0;i<=n;i++)
	{

	if (S[i]=='A')
	na=na+1;
	else if (S[i]=='D')
	nd=nd+1;
	}

	if(na>nd)
    printf("Aaton");
    else if(na<nd)
    printf("danik");
    else
    printf("friendship");
		return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
   printf("%d %d",a,d);

    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danik");
    else if(d==a)
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
    printf("%d %d",a,d);

    if((a+1)>d)
    printf("Anton");
    else if(d>a)
    printf("Danik");
    else if(d==a)
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
 //  printf("%d %d",a,d);

    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danik");
    else if(d==a)
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
    printf("%d %d",a,d);

    if((a+1)>d)
    printf("Anton");
    else if(d>(a+1))
    printf("Danik");
    else if(d==(a+1))
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
  //  printf("%d %d",a,d);

    if((a+1)>d)
    printf("Anton");
    else if(d>(a+1))
    printf("Danik");
    else if(d==(a+1))
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,i,a=0,d=0;

    scanf("%d",&n);
    char s[n];
        scanf("%s",s);
    for(i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        if(s[i]=='D')
        d++;

    }
 //  printf("%d %d",a,d);

    if(a>d)
    printf("Anton");
    else if(a<d)
    printf("Danik");
    else if(a==d)
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main(){
    int n,a=0,d=0;
    char s[1000];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i]=='A')
        a++;
        else if(s[i]=='D')
        d++;

    }
    if(a>d)
    printf("Anton");
    else if(d>a)
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char *a;
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c ",&a[i]);
	}

	while(i<n)
	{
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
}


//CF734-D2-A
#include<stdio.h>
#include<stdlib.h>

void result(int A,int B)
{
	if(A>B)
		printf("Anton");
	else
		if(B>A)
			printf("Danik");
		else
			printf("Friendship");
}

void input(char* a,int n)
{
	int i=0,anton=0,danik=0;
	printf("Enter %d times either 'A' or 'D' :-   ",n);
	while(i<n)
	{
		scanf("%c",&a[i]);
		if(a[i]=='D' || a[i]=='A')
		{
			if(a[i]=='A')
				anton++;
			else
				danik++;
			i++;
		}
	}
	result(anton,danik);
}

void main()
{
	int n;
	char *a;
	a=(char*)malloc(sizeof(char)*n);
	printf("Enter the number of times the match is played: ");
	while(1)
	{
		scanf("%d",&n);
		if(n>=1 && n<=1000)
			break;
		else
			printf("Please enter a number greater than zero and less than or equal to a thousand:-   ");
	}
	input(a,n);
}


//CF734-D2-A
#include<stdio.h>
#include<stdlib.h>

void result(int A,int B)
{
	if(A>B)
		printf("ANTON");
	else
		if(B>A)
			printf("DANIK");
		else
			printf("FRIENDSHIP");
}

void input(char* a,int n)
{
	int i=0,anton=0,danik=0;
	printf("Enter %d times either 'A' or 'D' :-   ",n);
	while(i<n)
	{
		scanf("%c",&a[i]);
		if(a[i]=='D' || a[i]=='d' || a[i]=='a' || a[i]=='A')
		{
			if(a[i]=='a' || a[i]=='A')
				anton++;
			else
				danik++;
			i++;
		}
	}
	result(anton,danik);
}

void main()
{
	int n;
	char *a;
	a=(char*)malloc(sizeof(char)*n);
	printf("Enter the number of times the match is played: ");
	while(1)
	{
		scanf("%d",&n);
		if(n>=1 && n<=1000)
			break;
		else
			printf("Please enter a number greater than zero and less than or equal to a thousand:-   ");
	}
	input(a,n);
}


#include<stdio.h>
#include<stdlib.h>

void main()
{
	long n,i=0,anton=0,danik=0;
	char *a;
	scanf("%ld",&n);
	a=(char*)malloc(sizeof(char)*n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c ",&a[i]);
	}
	i=0;
	while(i<n)
	{
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
}


#include<stdio.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
	exit(0);
}


#include<stdio.h>
void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton==danik)
		printf("Friendship");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Anton");
	exit(0);
}


#include<stdio.h>
void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton==danik)
		printf("Frienship");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Anton");
	exit(0);
}


#include<stdio.h>
#include<stdlib.h>

void result(int A,int B)
{
	if(A>B)
		printf("Anton");
	else
		if(B>A)
			printf("Danik");
		else
			printf("Friendship");
}

void input(char* a,int n)
{
	int i=0,anton=0,danik=0;
	printf("Enter %d times either 'A' or 'D' :-   ",n);
	while(i<n)
	{
		scanf("%c",&a[i]);
		if(a[i]=='D' || a[i]=='A')
		{
			if(a[i]=='A')
				anton++;
			else
				danik++;
			i++;
		}
	}
	result(anton,danik);
}

void main()
{
	int n;
	printf("%d",n);
	char *a;
	printf("Enter the number of times the match is played: ");
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	while(1)
	{
		if(n>=1 && n<=1000)
			break;
		else
			printf("Please enter a number greater than zero and less than or equal to a thousand:-   ");
	}
	input(a,n);
}


#include<stdio.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c",&a[i]);
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
	exit(0);
}


#include<stdio.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton==danik)
		printf("Frienship");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Anton");
	exit(0);
}


#include<stdio.h>
#include<stdlib.h>

void result(int A,int B)
{
	if(A>B)
		printf("Anton");
	else
		if(B>A)
			printf("Danik");
		else
			printf("Friendship");
}

void input(char* a,int n)
{
	int i=0,anton=0,danik=0;
	while(i<n)
	{
		scanf("%c",&a[i]);
		if(a[i]=='D' || a[i]=='A')
		{
			if(a[i]=='A')
				anton++;
			else
				danik++;
			i++;
		}
	}
	result(anton,danik);
}

void main()
{
	int n;
	char *a;
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	while(1)
	{
		if(n>=1 && n<=1000)
			break;
	}
	input(a,n);
}


#include<stdio.h>

int main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton==danik)
		printf("Friendship");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Anton");
	return 0;
}


#include<stdio.h>
void main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
	exit(0);
}


#include<stdio.h>
#include<stdlib.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char *a;
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	scanf("%s",a);
	while(i<n)
	{
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
}


#include<stdio.h>
#include<stdlib.h>

void main()
{
	long n,i=0,anton=0,danik=0;
	char *a;
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c ",&a[i]);
	}
	i=0;
	while(i<n)
	{
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
}


#include<stdio.h>

int main()
{
	int n,i=0,anton=0,danik=0;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf(" %c",&c);
		if(c=='A')
			anton++;
		else
			danik++;
	}
	if(anton==danik)
		printf("Frienship");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Anton");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>

void main()
{
	int n,i=0,anton=0,danik=0;
	char *a;
	scanf("%d",&n);
	a=(char*)malloc(sizeof(char)*n);
	for(i=0;i<n-1;i++)
	{
		scanf(" %c ",&a[i]);
	}
	i=0;
	while(i<n)
	{
		if(a[i]=='A')
			anton++;
		else
			danik++;
		i++;
	}
	if(anton>danik)
		printf("Anton");
	else
		if(danik>anton)
			printf("Danik");
		else
			printf("Friendship");
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100],c1=0,c2=0;
    scanf("%d\n",&num);
    scanf("%s\n",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[1000],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100],c1=0,c2=0;
    scanf("%d\n",&num);
    scanf("%s\n",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c2>c1)
    {
        printf("Danik");
    }
    else if(c1==c2)
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100000],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",&str);
    for(int i=0;i<num;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100],c1=0,c2=0;
    scanf("%d\n",&num);
    scanf("%s\n",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton\n");
    }
    else if(c2>c1)
    {
        printf("Danik\n");
    }
    else if(c1==c2)
    {
        printf("Friendship\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[num],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",str);
    for(int i=0;str[i]!='\0';i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[10000],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",&str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton\n");
    }
    else if(c2>c1)
    {
        printf("Danik\n");
    }
    else if(c1==c2)
    {
        printf("Friendship\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100000],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c1<c2)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",&str);
    int l=strlen(str);
    for(int i=0;i<l;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton\n");
    }
    else if(c2>c1)
    {
        printf("Danik\n");
    }
    else if(c1==2)
    {
        printf("Friendship\n");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    char str[100000],c1=0,c2=0;
    scanf("%d",&num);
    scanf("%s",&str);
    for(int i=0;i<num;i++)
    {
        if(str[i]=='A')
        {
            c1++;
        }
        else if(str[i]=='D')
        {
            c2++;
        }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    if(c2>c1)
    {
        printf("Danik");
    }
    if(c1==c2)
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int num;
    int c1=0,c2=0,i;
    char str[100000];
    scanf("%d",&num);
    scanf("%s",&str);
    for(i=0;i<num;i++)
    {
       if(str[i]=='A')
       {
           c1=c1+1;
       }
       if(str[i]=='D')
       {
           c2=c2+1;
       }
    }
    if(c1>c2)
    {
        printf("Anton");
    }
    else if(c2>c1)
    {
        printf("Danik");
    }
    else
    {
        printf("Friendship");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A'){
                  c++;
          }
          else if(s[i]=='D'){
               c1++;
          }
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      else if(c==c1)
          printf("Friendship");
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A')
          c++;
          else
          c1++;
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      if(c==c1)
          printf("Friendship");
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A'){
                  c++;
          }
          else{
               c1++;
          }
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      if(c==c1)
          printf("Friendship");
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A')
          c++;
          else if(s[i]=='D')
          c1++;
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      if(c==c1)
          printf("Friendship");
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[101]={'\0'};
     scanf("%s",s);
     int l=strlen(s),c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A')
          c++;
          else if(s[i]=='D')
          c1++;
     }
     if(c>c1){
          printf("Anton");
     }
     else if(c<c1){
          printf("Danik");
     }
     else if(c==c1){
          printf("Friendship");
     }
}


#include<stdio.h>
#include<string.h>
int main()
{
     long long int n;
     scanf("%d",&n);
     char s[100001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A'){
                  c++;
          }
          else if(s[i]=='D'){
               c1++;
          }
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      else if(c==c1)
          printf("Friendship");
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A')
          c++;
          else if(s[i]=='D')
          c1++;
     }
     if(c>c1){
          printf("Anton");
     }
     else if(c<c1){
          printf("Danik");
     }
     else if(c==c1){
          printf("Friendship");
     }
     return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
     long long int n;
     scanf("%d",&n);
     char s[1001]={'\0'};
     scanf("%s",s);
     int l=strlen(s);
     int c=0,c1=0;
     for(int i=0;i<l;i++){
          if(s[i]=='A'){
                  c++;
          }
          else if(s[i]=='D'){
               c1++;
          }
     }
     if(c>c1)
          printf("Anton");
     else if(c<c1)
          printf("Danik");
      else if(c==c1)
          printf("Friendship");
     return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int n ; char c;
	scanf("%d",&n) ;
	int a = 0 ;
	int d = 0 ;
	while(n--){
		scanf("%c",&c) ;
		if(c == 'A') a++ ;
		else d++ ;
	}
	if(a > d) printf("Danik");
	else if(a > d) printf("Anton") ;
	else  printf("Friendship") ;

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(){
	int n ; char c;
	scanf("%d",&n) ;
	int a = 0 ;
	int d = 0 ;
	while(n--){
		scanf("%c",&c) ;
		if(c == 'A') a++ ;
		else d++ ;
	}
	if(a > d) printf("Danik");
	else if(a < d) printf("Anton") ;
	else  printf("Friendship") ;

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

#define ll long long int
#define ull unsigned long long
#define FI(i,l,n) for(int i = l ; i < n ;i++)
#define FL(i,l,n) for(int i = l ; i < n ;i++)

int main(){
	int n ; char c;
	scanf("%d",&n) ;
	int a = 0 ;
	int d = 0 ;
	while(n--){
		scanf("%c",&c) ;
		if(c == 'A') a++ ;
		else d++ ;
	}
	if(a > d) printf("Danik");
	else if(a < d) printf("Anton") ;
	else  printf("Friendship") ;

	return 0;
}


#include<iostream>
using namespace std;
void DayofRoads(int **t,int r[],int n){
	if(n == 1){
		r[0] = 1;
		return;
	}
	r[0] = 1;
	int m = 0;
	int flag = 0;
	int a[n],b[n];
	a[m] = t[0][0];
	b[m] = t[0][1];
	for(int i = 1;i<n*n;i++){
		for(int k = 0;k<n;k++){
				if(a[k] == t[i][0]){
					flag = 1;
						break;
				}
			}
			if(flag == 1){
				flag = 0;
				continue;
			}
			for(int j = 0;j<n;j++){
				if(b[j] == t[i][1]){
					break;
				}
				if(j == n-1){
					a[++m] = t[i][0];
					b[m] = t[i][1];
					r[m] = i + 1;
				}
			}
	}
}
	int main(){
	int n;
	cin>>n;
	int **p;
	p = new int*[n*n];
	for(int i = 0 ;i<n*n;i++){
		p[i] = new int[2];
	}
	int *r;
	r = new int[n];
for(int i=0;i<n*n;i++)
{
for(int j=0;j<2;j++)
{
cin>>p[i][j];
}
}
DayofRoads(p,r,n);
for(int i=0;i<n;i++)
{
cout << r[i] << " ";
}

for(int i=0;i<n*n;i++)
{
delete [] p[i];
}
delete [] p;
delete [] r;

}


#include<iostream>
using namespace std;
void DayofRoads(int **t,int r[],int n){
	if(n == 1){
		r[0] = 1;
		return;
	}
	r[0] = 1;
	int m = 0;
	int flag = 0;
	int a[n],b[n];
	a[m] = t[0][0];
	b[m] = t[0][1];
	for(int i = 1;i<n*n;i++){
		flag = 0;
		for(int k = 0;k<n;k++){
				if(a[k] == t[i][0]){
					flag = 1;
						break;
				}
			}
			if(flag == 1){
				continue;
			}
			for(int j = 0;j<n;j++){
				if(b[j] == t[i][1]){
					break;
				}
				if(j == n-1){
					a[++m] = t[i][0];
					b[++m] = t[i][1];
					r[++m] = i;
				}
			}
	}
}
	int main(){
	int n;
	cin>>n;
	int **p;
	p = new int*[n*n];
	for(int i = 0 ;i<n*n;i++){
		p[i] = new int[2];
	}
	int *r;
	r = new int[n];
for(int i=0;i<n*n;i++)
{
for(int j=0;j<2;j++)
{
cin>>p[i][j];
}
}
DayofRoads(p,r,n);
for(int i=0;i<n;i++)
{
cout << r[i] << " ";
}

for(int i=0;i<n*n;i++)
{
delete [] p[i];
}
delete [] p;
delete [] r;

}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n*n+2],y[n*n+2],ar[n*n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
      //fr(i,1,n*n+1)
       //cout<<x[i]<<" "<<y[i]<<endl;

    int h[n*n+5],v[n*n+5];
    memset(h,0,sizeof(h));
    memset(v,0,sizeof(v));
    int j=0;
    for(i=1;i<=(n*n);i++)
    {    if(h[x[i]]==0&&v[y[i]]==0)
        {
              ar[j++]=i;
           //cout<<i<<" ";
               h[x[i]]=1;
               v[y[i]]=1;

        }

    }

    //for(i=0)
    fr(i,0,j)
       cout<<ar[i]<<" ";

return 0;
}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n+2],y[n+2],ar[n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
    map <int,int> m;
    int j=0;
    fr(i,1,n*n+1)
    {    if(m[x[i]]==0&&m[y[i]]==0)
        {
                     m[x[i]]++;
                     ar[j++]=i;

        }

    }
    fr(i,0,j)
             cout<<ar[i]<<" ";

return 0;
}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n+2],y[n+2],ar[n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
    int h[n*n+5],v[n*n+5];
    memset(h,0,sizeof(h));
    memset(v,0,sizeof(v));
    int j=0;
    fr(i,1,n*n+1)
    {    if(h[x[i]]==0&&v[y[i]]==0)
        {
               ar[j++]=i;
               h[x[i]]=1;
               v[y[i]]=1;

        }

    }
    fr(i,0,j)
             cout<<ar[i]<<" ";

return 0;
}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n+2],y[n+2],ar[n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
    int ar1[100000];
    memset(ar1,0,sizeof(ar1));
    int j=0;
    fr(i,1,n*n+1)
    {    if(ar1[x[i]]==0&&ar1[y[i]]==0)
        {
               ar[j++]=i;
               ar1[x[i]]=1;
               ar1[y[i]]=1;

        }

    }
    fr(i,0,j)
             cout<<ar[i]<<" ";

return 0;
}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n+2],y[n+2],ar[n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
    map <int,int> m;
    int j=0;
    fr(i,1,n*n+1)
    {    if(m[x[i]]==0&&m[y[i]]==0)
        {
                     m[x[i]]++;
                       m[y[i]]++;
                     ar[j++]=i;

        }

    }
    fr(i,0,j)
             cout<<ar[i]<<" ";

return 0;
}


#include<bits/stdc++.h>
#define fr(i,a,n) for(i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define ll long long
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
using namespace std;
int main()
{
    int n;
    si(n);
    int x[n+2],y[n+2],ar[n+2],i=0;
    fr(i,1,n*n+1)
    {
            si(x[i]);
            si(y[i]);

    }
    int h[100000],v[100000];
    memset(h,0,sizeof(h));
    memset(v,0,sizeof(v));
    int j=0;
    fr(i,1,n*n+1)
    {    if(h[x[i]]==0&&v[y[i]]==0)
        {
               ar[j++]=i;
               h[x[i]]=1;
               v[y[i]]=1;

        }

    }
    fr(i,0,j)
             cout<<ar[i]<<" ";

return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
bool a[51], b[51];
int main ()
{int n, i;
cin>>n;
for (i=0; i<=n*n;i++)
{int k,l;
cin>>k,l;
if (a[k]==0 && (b[l]==0))
{
a[k]=b[l]=true;
cout<<i+1<<endl;}}
return 0;}


#include <iostream>
using namespace std;
bool a[50], b[50];
int main ()
{int n, i;
cin>>n;
for (i=0; i<=n*n;i++)
{int k,l;
cin>>k,l;
if (a[k]==0 && (b[l]==0))
{
a[k]=b[l]=true;
cout<<i+1;}}}
S++;
else
S++;}
cout<<1<<S;
return 0;
}


include <iostream>
#include <stdio.h>
using namespace std;
bool a[50], b[50];
int main ()
{int n, i;
cin>>n;
for (i=0; i<=n*n;i++)
{int k,l;
cin>>k,l;
if (a[k]==0 && (b[l]==0))
{
a[k]=b[l]=true;
cout<<i+1;}}
return 0;}


#include <iostream>
#include <stdio.h>
using namespace std;
bool a[51], b[51];
int main ()
{int n, i;
cin>>n;
for (i=0; i<=n*n;i++)
{int k,l;
cin>>k>>l;
if (a[k]==0 && (b[l]==0))
{
a[k]=b[l]=true;
cout<<i+1<<endl;}}
return 0;}


#include <iostream>
using namespace std;
int main ()
{int n, a[n*n][2],S=1;
cin>>n;
for (int i=1; i<=n*n;i++)
for (int j=1;j<=2;j++)
cin>>a[i][j];
for (int i=2; i<=n*n;i++)
for (int j=1;j<=2;j++)
if ((i-1==i) && (j!=j-1))
{
if ((a[i]==a[i-1]) || (a[j]==a[j-1]))
S++;
else
S++;}
cout<<1<<S;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool arr1[51] , arr2[51] ;
int main()
{
    vector <int>ans ;
    int k , h , v ;

    cin >> k ;
    for(int i=0 ; i < k*k ; i++){
        cin >> h >> v ;
        if(!arr1[h] && !arr2[v]){
            arr1[h] = arr2[v] = true ;
            ans.push_back(i+1) ;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
bool arr[51] ;
int main()
{
    int n , h , v ;;
    vector <int>ans ;
    cin >> n ;
    for(int i=0 ; i < n*n ; i++){
        cin >> h >> v ;
        if(!arr[h] && !arr[v] || arr[h] && arr[v]){
            arr[h] =arr[v] = true ;
            ans.push_back(i+1) ;
        }
    }
    for(int i=0 ; i < ans.size() ; i++){
        cout << ans[i] << " " ;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool a[51] , b[51] ;
int main()
{
    int k , j , o ;
    vector <int>v ;
    cin >> k ;
    for(int i=0 ; i < k*k ; i++){
        cin >> j >> o ;
        if(!a[j] && !b[o]){
            a[j] = b[o] = true ;
            v.push_back(i+1) ;
        }
    }
    for(int i=0 ; i < v.size() ; i++)
        cout << v[i] << " " ;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
bool arr[51] ;
int main()
{
    int n , h , v ;;
    vector <int>ans ;
    cin >> n ;
    for(int i=0 ; i < n*n ; i++){
        cin >> h >> v ;
        if(!arr[h] && !arr[v]){
            arr[h] =arr[v] = true ;
            ans.push_back(i+1) ;
        }
    }
    for(int i=0 ; i < ans.size() ; i++){
        cout << ans[i] << " " ;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
bool arr[50] ;
int main()
{
    int n , h , v ;
    vector <int>ans ;
    cin >> n ;
    for(int i=0 ; i < n*n ; i++){
        cin >> h >> v ;
        if(!arr[h] && !arr[v]){
            arr[h] =arr[v] = true ;
            ans.push_back(i+1) ;
        }
    }
    for(int i=0 ; i < ans.size() ; i++){
        cout << ans[i] << " " ;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;
int roadx[51];
int roady[51];
int n;
bool work(int x,int y)
{
    if(roadx[x]==0&&roady[y]==0)
    {
        roadx[x] = roady[y] = 1;
        return true;
    }
    return false;
}
int main()
{
   int x,y;
   vector<int>output;

   while(cin>>n)
   {
       memset(roadx,0,sizeof(roadx));
       memset(roady,0,sizeof(roady));
       output.clear();
       for(int i=1;i<=n*n;i++)
       {
           cin>>x>>y;
           if(work(x,y))
                output.push_back(i);
       }
       for(int i=0;i<output.size()-1;i++)
            cout<<output[i]<<" ";
       cout<<output.back()<<endl;
   }
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define maxsize 51
using namespace std;

int main()
{
    int n;
    int hor[maxsize],inter[maxsize];
    bool signal[maxsize*maxsize];
    while(scanf("%d",&n)!=EOF&&n)
    {
        memset(hor,0,sizeof(hor));
        memset(inter,0,sizeof(inter));
        memset(signal,false,sizeof(signal));
        int cnt=0,x,y,t=0;
        for(int i=0; i<n*n; i++)
        {
            scanf("%d%d",&x,&y);
            cnt++;
            if((!hor[x])&&(!inter[y]))
            {
                hor[x]=inter[y]=1;
                signal[cnt]=true;
                t++;
            }
        }
        int m=0;
        for(int i=0; i<maxsize*maxsize; i++)
        {
            if(signal[i]&&m<t-1)
            {
                m++;
                printf("%d ",i);
            }
            else if(signal[i]&&m==t-1)
                printf("%d\n",i);
        }
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define maxsize 51
using namespace std;

int main()
{
    int n;
    int hor[maxsize],inter[maxsize];
    bool signal[maxsize];
    while(scanf("%d",&n)!=EOF&&n)
    {
        memset(hor,0,sizeof(hor));
        memset(inter,0,sizeof(inter));
        memset(signal,false,sizeof(signal));
        int cnt=0,x,y,t=0;
        for(int i=0; i<n*n; i++)
        {
            scanf("%d%d",&x,&y);
            cnt++;
            if((!hor[x])&&(!inter[y]))
            {
                hor[x]=inter[y]=1;
                signal[cnt]=true;
                t++;
            }
        }
        int m=0;
        for(int i=0; i<maxsize; i++)
        {
            if(signal[i]&&m<t-1)
            {
                m++;
                printf("%d ",i);
            }
            else if(signal[i]&&m==t-1)
                printf("%d\n",i);
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a[52]={0},b[52]={0},n,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n*n;i++){
        scanf("%d %d",&x,&y);
        if(a[x]==0&&b[y]==0){
            a[x]=1;
            b[y]=1;
            printf("%d",i);
        }
    }

return 0;
}


#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <memory.h>
using namespace std;
struct Point{
    int x,y;
}node[55*55];
int flag[55];
int n;
vector <int> res;
int main()
{
    scanf(" %d",&n);
        memset(flag,0,sizeof(flag));
        res.clear();
        int i;
        for(i=1;i<=n*n;i++){
            scanf(" %d %d",&node[i].x,&node[i].y);
            if(flag[node[i].x]==0&&flag[node[i].y]==0)
            {
                res.push_back(i);
                flag[node[i].x]=1;
                flag[node[i].y]=1;
            }
        }
        sort(res.begin(),res.end());
        for(i=0;i<res.size();i++)
        {
            printf("%d ",res[i]);
        }
        printf(" \n");
    return 0;
}


//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/11/6.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/10/25.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

#include<iostream>
#include<cstdio>
#include<map>
#include<climits>
#include<cmath>
#include<cstring>
#include<vector>
#include<cstdlib>
using namespace std;

int  visited_lineX[52];
int  visited_lineY[52];

//vector<int>road;
void initial()
{
    //road.clear();
    memset(visited_lineX,0,sizeof(visited_lineX));
    memset(visited_lineY,0,sizeof(visited_lineY));
}
int main()
{
    int n;

    scanf("%d",&n);
        initial();
        for(int i=1;i<=pow(n,2);i++)
        {
            int h,v;
            scanf("%d %d",&h,&v);
            //未被访问
            if(visited_lineX[h]==0 && visited_lineY[v]==0)
            {
                visited_lineX[h]=visited_lineY[h]=1;
                printf("%d ",i);
                //road.push_back(i);
            }
        }
       // for(int i=0;i<road.size();i++)
       // printf("%d ",road[i]);
        cout<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
int n;
int num[60][60]={0};

class Asphalting_Roads
{
    map<int,int> vx,vy;
    vector<int> day;
public:
    void initial();
    void read();
    void computing();
    void result();
};

void Asphalting_Roads::initial()
{
    vx.clear();
    vy.clear();
    day.clear();
    memset(num,0,sizeof(num));
}

void Asphalting_Roads::read()
{
    int x,y,counter=1;
    for(int i=1;i<=n*n;i++)
    {
        scanf("%d%d",&x,&y);
        if(vx.find(x)==vx.end()&&vy.find(y)==vy.end())
        {
            day.push_back(counter);
            vx.insert(pair<int,int>(x,0));
            vy.insert(pair<int,int>(y,0));
        }
        counter++;
    }
}

void Asphalting_Roads::result()
{
    for(int i=0;i<day.size();i++)
    {
        if(i==0)
            cout<<day[i];
        else
            cout<<" "<<day[i];
    }
    cout<<endl;
}

int main()
{
    Asphalting_Roads ar;
    while(scanf("%d",&n)!=EOF)
    {
        ar.initial();
        ar.read();
        ar.result();
    }
    return 0;
}


//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/11/6.
//  Copyright © 2016年 sky.dai. All rights reserved.
//
//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/10/25.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

#include<iostream>
#include<cstdio>
#include<map>
#include<climits>
#include<cmath>
#include<cstring>
#include<vector>
#include<cstdlib>
using namespace std;

int  visited_lineX[52];
int  visited_lineY[52];

//vector<int>road;
void initial()
{
    //road.clear();
    memset(visited_lineX,0,sizeof(visited_lineX));
    memset(visited_lineY,0,sizeof(visited_lineY));
}
int main()
{
    int n;
       scanf("%d",&n);
        initial();
        for(int i=1;i<=n*n;i++)
        {
            int h,v;
            scanf("%d %d",&h,&v);
            //未被访问
            if(visited_lineX[h]==0 && visited_lineY[v]==0)
            {
                visited_lineX[h]=1;
                visited_lineY[v]=1;
                printf("%d ",i);
            }
        }
       //for(int i=0;i<road.size();i++)
       //printf("%d ",road[i]);
    return 0;
}


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

int main()
{    int x[3000],y[3000],c[3000];
     int n;
     while(scanf("%d",&n)!=EOF)
     {
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        n*=n;int date=0,p=0;
        for(int i=0;i<n;i++)
        {  date++;
            int num1,num2;
            scanf("%d%d",&num1,&num2);
            if(x[num1]==0&&y[num2]==0)
            {
                x[num1]=1;
                y[num2]=1;
               c[p++]=date;
            }
        }
        for(int j=0;j<p-1;j++)
        {
          printf("%d ",c[j]);
        }
        printf("%d\n",c[p-1]);
     }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main()
{
    int n;
    while(cin>>n){
        int t=0,q=0;
        int day[n+1];
        int x[n+1],y[n+1],m,nn;
        for(int i=1;i<=n+1;i++){
            x[i]=y[i]=day[i]=0;
        }
        while(cin>>m>>nn){
            t++;
            if(x[m]==1||y[nn]==1){
                continue;
            }
            else{
                x[m]=1;
                y[nn]=1;
                q++;
                day[q]=t;
            }
            if(t==n*n) break;
        }
        for(int i=1;i<=q;i++){
            cout<<day[i];
            if(i!=q) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
vector<bool> x;
vector<bool> y;
int n;
int day = 0;
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	int t = 0;
	cin >> n;
	x.resize(n);
	y.resize(n);
	for(int i = 0; i < n; ++i)
	{
		x[i] = false;
		y[i] = false;
	}
	for(int i = 0; i < n*n; ++i)
	{
		cin >> a >> b;
		if(t == n) continue;
		if(!x[a] && !y[b])
		{
			x[a] = true;
			y[b] = true;
			t++;
		}

		//cout << "I am t" << t << endl;
		//cout << "is this running?" << endl;
		day++;
	}
	if(day == 1)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 1 << " " << day << endl;
	}
	return 0;
}


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

int main()
{
    int x[55],y[55];//ans[55];
    int n;
    cin>>n;
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        memset(ans,0,sizeof(ans));
        int xx,yy;
        for(int i=1;i<=n*n;i++)
        {
            cin>>xx>>yy;
            if(x[xx]==0&&y[yy]==0)
            {
                x[xx]=1;
                y[yy]=1;
                cout<<i<<" ";
            }
        }
    return 0;
}


#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include <cstdio>
#include <cstring>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
int x[2510];
int y[2510];
int main(){
    int n;
    while(cin>>n)
    {
        vector<int> a;
        a.clear();
        int b,c;
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        for(int i=1;i<=n*n;i++)
        {
            cin>>b>>c;
            if(!x[b]&&!y[c])
            {
                a.push_back(i);
                x[b]=1;
                y[c]=1;
            }
        }
        cout<<a[0];
        for(int i=1;i<a.size();i++)
        {
            cout<<" "<<a[i];
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t=n*n;
	int a[51],b[51];
	int h,v;
    for(int i=1;i<=t;i++){
		cin>>h>>v;
		if(a[h]!=1 && b[v]!=1){
			cout<<i<<" ";
			a[h]=1;
			b[v]=1;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t=n*n;
	int a[51],b[51];
	int h,v;
    for(int i=1;i<=t;t++){
		cin>>h>>v;
		if(a[h]!=1 && b[v]!=1)
		    cout<<i<<" ";
		a[h]=b[v]=1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t=n*n;
	int a[51],b[51];
	int h,v;
    for(int i=1;i<=t;i++){
		cin>>h>>v;
		if(a[h]!=1 && b[v]!=1)
		    cout<<i<<" ";
		a[h]=b[v]=1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n*n;i++){
		int x,y;
		cin>>x>>y;
	}
	cout<<"1 ";
	for(int i =1;i<n;i++){
	    cout<<n+i+1;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int t=n*n;
	int a[51],b[51];
	vector<int> result;
	vector<int>::iterator it;
	for(int i=1;i<=t;t++){
		int h,v;
		cin>>h>>v;
		if(a[h]!=1 && b[v]!=1)
		    cout<<i<<" ";
		a[h]=b[v]=1;
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 20009

pair<int, int> array[MAX];
int v[MAX], n;

int main()
{
    for(int i=0;i<MAX;i++)
        v[i]=0;
    scanf("%d", &n);
    for(int i = 0; i < n * n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);

    int t= 0;
    for(int i = 0; i < n * n; i++)
    {
        int f = array[i].first, s = array[i].second;
        if(v[f] == 0 && v[s] == 0)
        {
            v[f] = v[s] = 1;
            if(t > 0)
                printf(" ");
            else
            t++;

            printf("%d", i + 1);
        }

    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 20009

pair<int, int> array[MAX];
int v[MAX], n;

int main()
{
    memset(v, 0, sizeof(v));
    scanf("%d", &n);
    for(int i = 0; i < n * n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);
    int t= 0;
    for(int i = 0; i < n * n; i++)
    {
        int f = array[i].first, s = array[i].second;
        if(v[f] == 0 && v[s] == 0)
        {
            v[f] = v[s] = 1;
            if(t > 0)
                printf(" ");
            else
            t++;

            printf("%d", i + 1);
        }

    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 20009

pair<int, int> array[MAX];
int v[MAX],n;

int main()
{
    memset(v, 0, sizeof(v));
    scanf("%d", &n);
    for(int i = 0; i < n*n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);

    for(int i=0;i<n*n;i++)
    {
        int f=array[i].first,s=array[i].second;
        if(v[f]==0 && v[s]==0)
        {
            v[f]=v[s]=1;
            printf("%d ",i+1);
        }

    }
    pintf("\n");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 20009

pair<int, int> array[MAX];
int v[MAX], n;
int v2[MAX];

int main()
{
    for(int i=0;i<MAX;i++)
        v[i]=0,v2[i];
    scanf("%d", &n);
    for(int i = 0; i < n * n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);

    int t= 0;
    for(int i = 0; i < n * n; i++)
    {
        int f = array[i].first, s = array[i].second;
        if(v[f] == 0 && v2[s] == 0)
        {
            v[f] = v2[s] = 1;
            if(t > 0)
                printf(" ");
            else
            t++;

            printf("%d", i + 1);
        }

    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 200009

pair<int, int> array[MAX];
int v[MAX], n;

int main()
{
    for(int i=0;i<MAX;i++)
        v[i]=0;
    scanf("%d", &n);
    for(int i = 0; i < n * n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);

    int t= 0;
    for(int i = 0; i < n * n; i++)
    {
        int f = array[i].first, s = array[i].second;
        if(v[f] == 0 && v[s] == 0)
        {
            v[f] = v[s] = 1;
            if(t > 0)
                printf(" ");
            else
            t++;

            printf("%d", i + 1);
        }

    }
    printf("\n");

    return 0;
}


#include <iostream>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define MAX 20009

pair<int, int> array[MAX];
int v[MAX],n;

int main()
{
    memset(v, 0, sizeof(v));
    scanf("%d", &n);
    for(int i = 0; i < n*n; i++)
        scanf("%d %d", &array[i].first, &array[i].second);

    for(int i=0;i<n*n;i++)
    {
        int f=array[i].first,s=array[i].second;
        if(v[f]==0 && v[s]==0)
        {
            v[f]=v[s]=1;
            printf("%d ",i+1);
        }

    }
    printf("\n");

    return 0;
}


#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    int a[53]={0};
    int b[53]={0};
    int turn;
    scanf("%d",&turn);
    for(int i=1;i<=turn*turn;i++)
    {
        int va,vb;
        scanf("%d %d",&va,&vb);
        if(a[va]==0&&b[vb]==0)
        {
            a[va]=1;
            b[vb]=1;
            printf("%d ",i);
        }
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#define maxsize 51
using namespace std;

int hor[maxsize],inter[maxsize];
int main()
{
    int n;
    bool signal[maxsize];
    while(scanf("%d",&n)!=EOF)
    {
        memset(hor,0,sizeof(hor));
        memset(inter,0,sizeof(inter));
        memset(signal,false,sizeof(signal));
        int cnt=0,x,y,t=0;
        for(int i=0; i<n*n; i++)
        {
            scanf("%d%d",&x,&y);
            cnt++;
            if((hor[x]==0)&&(inter[y]==0))
            {
                hor[x]=1;
                inter[y]=1;
                signal[cnt]=true;
                t++;
            }
        }
        int m=0;
        for(int i=0; i<51; i++)
        {
            if(signal[i]&&m<t)
            {
                m++;
                printf("%d ",i);
            }
            else if(signal[i]&&m==t)
                printf("%d\n",i);
        }
    }
    return 0;
}


//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/11/6.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/10/25.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

#include<iostream>
#include<cstdio>
#include<map>
#include<climits>
#include<cmath>
#include<cstring>
#include<vector>
#include<cstdlib>
using namespace std;

int  visited_lineX[52];
int  visited_lineY[52];

//vector<int>road;
void initial()
{
    //road.clear();
    memset(visited_lineX,0,sizeof(visited_lineX));
    memset(visited_lineY,0,sizeof(visited_lineY));
}
int main()
{
    int n;

       scanf("%d",&n);
        initial();
        for(int i=1;i<=n*n;i++)
        {
            int h,v;
            scanf("%d %d",&h,&v);
            //未被访问
            if(visited_lineX[h]==0 && visited_lineY[v]==0)
            {
                visited_lineX[h]=1;
                visited_lineY[h]=1;
                printf("%d ",i);
                //road.push_back(i);
            }
        }
       // for(int i=0;i<road.size();i++)
       // printf("%d ",road[i]);
        cout<<endl;
    return 0;
}


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

int main()
{
    int x[55],y[55],ans[55];
    int n;
    cin>>n;
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        memset(ans,0,sizeof(ans));
        int xx,yy;
        for(int i=1;i<=n*n;i++)
        {
            cin>>xx>>yy;
            if(x[xx]==0&&y[yy]==0)
            {
                ans[i]=1;
                x[xx]=1;
                y[yy]=1;
            }
        }
        for(int i=1;i<=n*n;i++)
        {
            if(ans[i])
            {
                cout<<i<<" ";
            }
        }
    return 0;
}


#include <cstring>
using namespace std;
struct Map{
    int x,y;
}mymap[55*55];
int nodex[55];
int nodey[55];
int n;
vector <int> res;
int main()
{
        scanf(" %d",&n);
        memset(nodex,0,sizeof(nodex));
        memset(nodey,0,sizeof(nodey));
        res.clear();
        int i;
        for(i=1;i<=n*n;i++){
            scanf(" %d %d",&mymap[i].x,&mymap[i].y);
            if(nodex[mymap[i].x]==0&&nodey[mymap[i].y]==0)
            {
                res.push_back(i);
                nodex[mymap[i].x]=1;
                nodey[mymap[i].y]=1;
            }
        }
        sort(res.begin(),res.end());
        for(i=0;i<res.size();i++)
        {
            printf("%d ",res[i]);
        }
        printf(" \n");
    return 0;
}


#include <iostream>

using namespace std;

class road
{
public:
    int x=0,y=0;
};
int main()
{
    int n,a,b,i;
    road street[55];
    while(cin>>n)
    {
        for(i=1;i<=n*n;i++)
        {
            cin>>a>>b;
            if(street[a].x==0&&street[b].y==0)
            {
                street[a].x=1;
                street[b].y=1;
                cout<<i<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <map>

using namespace std;

class AsphaltingRoads
{
private:
    map <int,bool> mx,my;
    vector <int> ans;
public:
    void initial()
    {
        mx.clear();
        my.clear();
        ans.clear();
    }
    void check(int n)
    {
        int x,y;
        for (int i=1;i<=n*n;i++)
        {
            cin>>x>>y;
            if (mx[x]==false&&my[y]==false)
            {
                ans.push_back(i);
                mx[x]=true;
                my[y]=true;
            }
        }
    }
    void outResult()
    {
        for(int i=0;i<ans.size();i++)
        {
            cout<<ans[i]<<" ";
        }
        cout<<endl;
    }
};

int main()
{
    int n;
    AsphaltingRoads ar;
    while(cin>>n)
    {
        ar.initial();
        ar.check(n);
        ar.outResult();
    }
    return 0;
}


//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/11/6.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

//
//  main.cpp
//  ceshi
//
//  Created by 戴志扬 on 2016/10/25.
//  Copyright © 2016年 sky.dai. All rights reserved.
//

#include<iostream>
#include<cstdio>
#include<map>
#include<climits>
#include<cmath>
#include<cstring>
#include<vector>
#include<cstdlib>
using namespace std;

int  visited_lineX[10000];
int  visited_lineY[10000];

//vector<int>road;
void initial()
{
    //road.clear();
    memset(visited_lineX,0,sizeof(visited_lineX));
    memset(visited_lineY,0,sizeof(visited_lineY));
}
int main()
{
    int n;
    int road[5100];
    int ind;

    while (scanf("%d",&n) && n)
    {
        ind  =0;
        initial();
        for(int i=1;i<=pow(n,2);i++)
        {
            int h,v;
            scanf("%d %d",&h,&v);
            //未被访问
            if(visited_lineX[h]==0 && visited_lineY[v]==0)
            {
                visited_lineX[h]=visited_lineY[h]=1;
                //road.push_back(i);
                road[ind++] = i;
            }
        }
        //cout<<road[0];
        for(int i=0;i<ind;i++)
        printf("%d ",road[i]);
        cout<<endl;
    }
    return 0;
}


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

int main()
{    int x[3000],y[3000],c[3000];
    int n;
     while(scanf("%d",&n)!=EOF)
     {
        memset(x,0,sizeof(x));
        memset(y,0,sizeof(y));
        n*=n;int date=0,p=0;
        for(int i=0;i<n;i++)
        {  date++;
            int num1,num2;
            scanf("%d%d",&num1,&num2);
            if(x[num1]==0&&x[num2]==0)
            {
                x[num1]=1;
                y[num2]=1;
               c[p++]=date;
            }
        }
        for(int j=0;j<p-1;j++)
        {
          printf("%d ",c[j]);
        }
        printf("%d\n",c[p-1]);
     }
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a[52]={0};
    int b[52]={0};
    int i,n,x,y;
    scanf("%d",&n);
    for( i=1;i<=n*n;i++){
        scanf("%d %d",&x,&y);
        if(a[x]==0 && b[y]==0){
            a[x]=1;
            b[y]=1;
            printf("%d",i);
        }
    }

return 0;
}


#include<stdio.h>
#include <string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n, a, b;
	int x[51] = { 0 };
	int y[51] = { 0 };
	scanf("%d", &n);
	int i;
	for (i = 1; i <= n*n; i++)
	{
		scanf("%d %d", &a, &b);
		if (x[a] == 0 && y[b] == 0)
		{
			x[a] = 1;
			y[b] = 1;
			printf("%d ", i);
		}
	}
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,h[55],v[55],cn,m,wa,we;
	cin>>n;
	cn=n*n;
	for(int i=1;i<=cn;i++){
	cin>>h[i]>>v[i];
	}
	for(int e=1;e<=cn;e++){
		if(h[e]!=0){
		cout<<e<<" ";
		wa=h[e];
		we=v[e];
			for(int o=1;o<=cn;o++){
			if(h[o]==wa||v[o]==we){
			h[o]=0;
			}
			}
		}
	}
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,h[55],v[55],cn,inicial;
	cin>>n;
	cn=n*n;
	for(int i=1;i<=cn;i++){
	cin>>h[i]>>v[i];
	}
	inicial=h[1]+v[1];
	for(int e=1;e<=cn;e++){
	if(h[e]+v[e]==inicial){
	cout<<e<<" ";
	}
	}
	return 0;


#include <iostream>
using namespace std;

int main() {
	int n,h[55],v[55],cn,m,wa,we,i,e,o;
	cin>>n;
	cn=n*n;
	for(int i=1;i<=cn;i++){
	cin>>h[i]>>v[i];
	}
	for(int e=1;e<=cn;e++){
		if(h[e]!=0&&v[e]!=0){
		cout<<e<<" ";
		wa=h[e];
		we=v[e];
			for(int o=1;o<=cn;o++){
			if(h[o]==wa||v[o]==we){
			h[o]=0;
			v[o]=0;
			}
			}
		}
	}
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,h[2510],v[2510],cn,m,wa,we;
	cin>>n;
	cn=n*n;
	for(int i=1;i<=cn;i++){
	cin>>h[i]>>v[i];
	}
	for(int e=1;e<=cn;e++){
		if(h[e]!=0){
		cout<<e<<" ";
		wa=h[e];
		we=v[e];
			for(int o=1;o<=cn;o++){
			if(h[o]==wa||v[o]==we){
			h[o]=0;
			}
			}
		}
	}
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int n,h[55],v[55],cn;
	cin>>n;
	cn=n*n;
	for(int i=1;i<=cn;i++){
	cin>>h[i]>>v[i];
	}
	for(int e=1;e<=cn;e++){
	if(h[e]==v[e]){
	cout<<e<<" ";
	}
	}
	return 0;
}


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

    int main(){
        ll a,b,n;
        cin>>n;
        std::vector< std::vector< ll > > v ( n+1, std::vector<ll> ( 2, 0 ) );
        vector<ll>c;
        ll day=0;
        for(ll i=0;i<n*n;i++){
            cin>>a>>b;
            day++;
            if(v[a][0]==0&&v[b][1]==0){
                c.push_back(day);
                v[a][0]=1;
                v[b][1]=1;
            }
        }
        sort(c.begin(),c.end());
        for(ll i=0;i<c.size();i++) cout<<c[i]<<" ";
    }


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

    int main(){
        ll a,b,n;
        cin>>n;
        vector<ll>v(n+1,0);
        vector<ll>c;
        ll day=0;
        for(ll i=0;i<n*n;i++){
            cin>>a>>b;
            day++;
            if(v[a]==0&&v[b]==0){
                c.push_back(day);
                v[a]=1;
                v[b]=1;
            }
        }
        sort(c.begin(),c.end());
        for(ll i=0;i<c.size();i++) cout<<c[i]<<" ";
    }


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

int main(){
    ll a,b,n;
    cin>>n;
    vector<ll>v(n,0);
    vector<ll>c;
    ll day=0;
    for(ll i=0;i<n*n;i++){
        cin>>a>>b;
        day++;
        if(v[a]==0&&v[b]==0){
            c.push_back(day);
            v[a]=1;
            v[b]=1;
        }
    }
    sort(c.begin(),c.end());
    for(ll i=0;i<c.size();i++) cout<<c[i]<<" ";
}


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

int main(){
    ll a,b,n;
    cin>>n;
    vector<ll>v(n+1,0);
    vector<ll>c;
    ll day=0;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        day++;
        if(v[a]==0&&v[b]==0){
            c.push_back(day);
            v[a]=1;
            v[b]=1;
        }
    }
    sort(c.begin(),c.end());
    for(ll i=0;i<c.size();i++) cout<<c[i]<<" ";
}


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

int main(){
    ll a,b,n;
    cin>>n;
    vector<ll>v(n,0);
    vector<ll>c;
    ll day=0;
    for(ll i=0;i<n;i++){
        cin>>a>>b;
        day++;
        if(v[a]==0&&v[b]==0){
            c.push_back(day);
            v[a]=1;
            v[b]=1;
        }
    }
    sort(c.begin(),c.end());
    for(ll i=0;i<c.size();i++) cout<<c[i]<<" ";
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100],b[100];
cin>>n;
for (int i=1; i<=n*n; i++)
       {

           cin>>a[i]>>b[i];
           if ((a[i-1]!=a[i]) && (b[i-1]!=b[i])) cout<<i<<' ';
       }
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100][100];
cin>>n;
for (int i=1; i<=n*n; i++)
      for (int j=1; j<=2; j++)
        cin>>a[i][j];
cout<<1<<' ';
int l=1;
while (l!=n*n)
      {

        l=l+n+1;
        cout<<l<<' ';
      }

return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100],b[100];
cin>>n;
for (int i=1; i<=n*n; i++)
       {

           cin>>a[i]>>b[i];
           if (a[i]==b[i]) cout<<i<<' ';
           if ((a[i-1]!=a[i]) && (b[i-1]!=b[i])) cout<<i<<' ';
       }
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100],b[100];
cin>>n;
for (int i=1; i<=n*n; i++)
       {

           cin>>a[i]>>b[i];
           if (a[i-1]!=a[i]) && (b[i-1]!=b[i]) cout<<i<<' ';
       }
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100][100],l,k;
cin>>n;
for (int i=1; i<=n*n; i++)
       {

           cin>>l>>k;
           if (l==k) cout<<i<<' ';
       }
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,k,l,s=0,a[100]={0},b[100]={0};
cin>>n;
for (int i=1; i<=n*n; i++)
       {
        cin>>k>>l;
        if (a[k]==0)
            if (b[l]==0)
         {
             a[k]=1;
        b[l]=1;
             cout<<i<<' ';
         }
       }
return 0;
}


#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main () {
int n,a[100][100];
cin>>n;
for (int i=1; i<=n*n; i++)
      for (int j=1; j<=2; j++)
        cin>>a[i][j];
cout<<1<<' ';
int l=1;
while (l<=n*n)
      {

        l=l+n+1;
        cout<<l<<' ';
      }

return 0;
}