///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   Every soul shall taste death.

///   Tag ::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

/// faster.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;

#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

using ll = long long;
const ll MOD = 1e9 + 7;

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

/// Modular arithmetic
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }  /// When MOD is prime.
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

//***********************************************  The END **********************************************************************************************************************************
const ll N = 1e6;
const ll INF = 1e15;

ll n , d , m , tot = 0;

int main()
{

   MOHAMMAD

   ll t = 1;

   /// cin >> t;

   while ( t-- ){

        cin >> n >> d >> m;
        ll a[n+1] = { 0 };
        for ( ll i = 1 ; i<=n ; i++ ){
                cin >> a[i];
                if(a[i]>m) tot++;
        }

        sort ( a+1 , a+n+1 , greater<ll>() );

        for ( ll i = 2 ; i<=n ; ++i ) {
             a[i] = a[i-1] + a[i];
        }

        if ( !tot ) {
                cout << a[n];
                return 0;
        }

        ll ans = 0;

        for ( ll i = 1 ; i<=tot ; ++i ){
             ll cut = n - ((i-1)*(d+1) + 1);
             if(cut>=0)ans = max ( ans , a[i] + a[min(n,i+cut)] - a[tot] );
        }

        cout << ans << "\n";

   }
}

/*

  Alhamdulillah
*/


///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   Every soul shall taste death.

///   Tag ::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

/// faster.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;

#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

using ll = long long;
const ll MOD = 1e9 + 7;

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)

/// Modular arithmetic
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }  /// When MOD is prime.
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

//***********************************************  The END **********************************************************************************************************************************
const ll N = 1e6;
const ll INF = 1e15;

ll n , d , m , tot = 0;

int main()
{

   MOHAMMAD

   ll t = 1;

   /// cin >> t;

   while ( t-- ){

        cin >> n >> d >> m;
        ll a[n+1] = { 0 };
        for ( ll i = 1 ; i<=n ; i++ ){
                cin >> a[i];
                if(a[i]>m) tot++;
        }

        sort ( a+1 , a+n+1 , greater<ll>() );

        for ( ll i = 1 ; i<=n ; ++i ) {
             a[i] = a[i-1] + a[i];
        }

        if ( !tot ) {
                cout << a[n];
                return 0;
        }

        ll ans = 0;

        for ( ll i = 1 ; i<=tot ; ++i ){
             ll cut = n - ((i-1)*(d+1) + 1);
             if(cut>=0)ans = max ( ans , a[i] + a[min(n,i+cut)] - a[tot] );
        }

        cout << ans << "\n";

   }
}

/*

  Alhamdulillah
*/


#include <iostream>
#include <string>
using namespace std;
 int main () {
 int a , count1=0 ,count2=0;
 cin >> a;
 string s;
 cin >> s;
 for (int i=1; i<a; i++){
   if (s[i] == 'A') {
    count1++;

 }
 else if (s[i] == 'D'){
    count2++;
 }

 }
if (count1 > count2){
    cout << "Anton" << endl;
}
else if (count1 < count2) {
    cout << "Danik" << endl;
}
else if (count1 == count2){
    cout << "Friendship" << endl;
}

 }


#include <iostream>
using namespace std;
int main (){
int n ;
int z =0;
int v=0;
string g;
cin >> n;
for (int i=1; i<=6; i++){
    cin >> g;

    if (g =="A"){
        z=z+1;
    }else{
    v=v+1;}}
if (z>v){
    cout << "Anton" << endl;
}
else if (v>z){
    cout << "Danik" << endl;

}
else {
    cout << "Friendship" << endl;
}

}


#include <iostream>
using namespace std;
int main (){
int n ;
int a =0;
int d=0;
string g;
cin >> n;
for (int i=1; i<=6; i++){
    cin >> g;

    if (g =="A"){
        a=a+1;
    }else{
    d=d+1;}}
if (a>d){
    cout << "Anton" << endl;
}
else if (d>a){
    cout << "Danik" << endl;

}
else {
    cout << "Friendship" << endl;
}

}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	while(x){

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else if ( a == d && x !=0 ) {
			cout<< "Freindship";
		}

}

}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	while ( x ){

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}
}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;
	if ( x >= 1){

	for( int i = 1 ; i <= x ; i++ ){

		cin>>arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else  {
					d = d + 1 ;
				}
					}

	if (a>d){

			cout<<"Anton";

	}
	 else if (d>a){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}

}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>>arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if (a>d){

			cout<<"Anton";

	}
	 else if (d>a){

		cout<<"Danik";
		}

		else if (a==d) {
			cout<< "Freindship";
		}

	}


#include <iostream>
using namespace std;

int main ()
{
    int n,i,a,d;
    char ch;

    while (cin >> n)
    {
        a = 0;
        d = 0;

        for (i=1; i<=n; i++)
        {
            cin >> ch;

            if (ch == 'A')
                a = a + 1;
            else
                d = d + 1;
        }

        if (a > d)
            cout << "Anton" << endl;
        else if (d > a)
            cout << "Danik" << endl;
        else
            cout << "Friendship" << endl;
    }

    return 0;
}


#include <iostream>
using namespace std;

int main ()
{

    int x , a = 0 , d = 0;
	char str;
	cin>>x;

		for ( int i = 0; i < x ; i++){
			cin>>str;
			if ('A' == str){
				a++;
			}
			else{
				d++;
			}
		}

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

	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include<string.h>

using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<" \"ANTON\" ";
		}

	 else if ( d > a  ){

			cout<<" \"DANIK\" ";
		}

		else {
			cout<< " \"Freindship\"";
		}

	}


#include <iostream>
using namespace std;

int main ()
{

   unsigned int x , a  , d;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

		for ( int i = 1; i <= x ; i++){

			cin>>str;
			if ('A' == str){
				a++;
			}
			else{
				d++;
			}
		}

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

}
	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	while(x){

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else if ( a == d && x !=0 ) {
			cout<< "Friendship";
		}

}

}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else if ( a == d && x !=0 ) {
			cout<< "Freindship";
		}

}


#include <iostream>
using namespace std;

int main ()
{

   unsigned int x , a  , d;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

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

			cin>>str;
			if ('A' == str){
				a++;
			}
			else{
				d++;
			}
		}

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

}
	}


#include <iostream>
using namespace std;
int main ()
{

    int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a = 0;
		d = 0;

		for (i = 1; i <= x ; i++){

			cin>>str;

			if (str=='A')
				a=a+1 ;

			else
				d=d+1;

		}

		if (a>d)
		cout<< "Anton"<<"\n";
		else if
		 (d>a)	cout<< "Danik"<<"\n";
		 else
		 	cout<< "Friendship"<<"\n";

}
	return  0 ;
	}


#include <iostream>
using namespace std;

int main ()
{

   unsigned int x , a  , d;
	char str;
	cin>>x;

	while ( x ){
		a=0;d=0;
		for ( int i = 0; i < x ; i++){

			cin>>str;
			if ('A' == str){
				a++;
			}
			else{
				d++;
			}
		}

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

}
	}


#include<iostream>
using namespace std;
int main() {

	unsigned int x ;

		int n = 1  , y = 0 , i ;
		cin >> x ;

		for ( i = 1 ; i <= x ; i = i * 2  ) {
			y = x - i + 1;
		}

		if (y < 0) {
			cout <<y * - 1 ;
		}
		else {
			cout << y ;
		}

}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include<string.h>

using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<" anton ";
		}

	 else if ( d > a  ){

			cout<<" danik ";
		}

		else {
			cout<<" freindship";
		}

	}


#include <iostream>
using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a  ){

			cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin >> x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr == 'A'){
			a = a + 1 ;
		}
		else if (arr == 'D' )  {
			d = d + 1 ;
		}
	}

	if ( a > d ){
		cout<<"Anton";
	}
	 else if ( d > a ){
	 	cout<<"Danik";
	}
	else if ( a == d  ) {
		cout<< "Friendship";
	}

		return 0 ;
}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>>arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else  {
					d = d + 1 ;
				}
					}

	if (a>d){

			cout<<"Anton";

	}
	 else if (d>a){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include<string.h>

using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<" ANTON ";
		}

	 else if ( d > a  ){

			cout<<" DANIK ";
		}

		else {
			cout<< " Freindship";
		}

	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;
	if ( x >= 1){

	for( int i = 1 ; i < x ; i++ ){

		cin>>arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else  {
					d = d + 1 ;
				}
					}

	if (a>d){

			cout<<"Anton";

	}
	 else if (d>a){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}

}


#include <iostream>
using namespace std;

int main ()
{

    int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

		for (  i = 1; i <= x ; i++){

			cin>>str;

			if (str == 'A'){
				a = a + 1 ;
			}
			else{
				d = d + 1;
			}
		}

		if (a>d)	cout<<"Anton"<<"\n";
		else if (d>a)	cout<<"Danik"<<"\n";
		 else{
		 	cout<<"friendship"<<"\n";
		 }

}
	}


#include <iostream>
using namespace std;

int main ()
{

    int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

		for (  i = 1; i <= x ; i++){

			cin>>str;

			if (str == 'A'){
				a = a + 1 ;
			}
			else{
				d = d + 1;
			}
		}

		if (a>d)	cout<<"Anton"<<"\n";
		else if (d>a)	cout<<"Danik"<<"\n";
		 else{
		 	cout<<"friendship"<<"\n";
		 }

}
	return  0 ;
	}


#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include<string.h>

using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"ANTON";
		}

	 else if ( d > a  ){

			cout<<"DANIK";
		}

		else {
			cout<< "Freindship";
		}

	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){
			a = a + 1 ;

			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else if ( a == d && 0) {
			cout<< "Freindship";
		}

}


#include <iostream>
using namespace std;
int main(){

	int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if ( arr  ==  'A'){

					a = a + 1 ;
				}

				else  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	 else if ( d > a  ){

			cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}


#include <iostream>
using namespace std;

int main ()
{

    int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

		for (  i = 1; i <= x ; i++){

			cin>>str;

			if (str == 'A'){
				a++;
			}
			else{
				d++;
			}
		}

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

}
	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;
	if ( x >= 1){

	for( int i = 1 ; i <= x ; i++ ){

		cin>>arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else  {
					d = d + 1 ;
				}
					}

	if (a>d){

			cout<<"Anton";

	}
	 else if (d>a){

		cout<<"Danik";
		}

		else {
			cout<< "Freindship";
		}

	}

}


#include <iostream>
using namespace std;

int main ()
{

   unsigned int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a=0;
		d=0;

		for (  i = 1; i <= x ; i++){

			cin>>str;

			if (str == 'A'){
				a++;
			}
			else{
				d++;
			}
		}

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

}
	}


#include <iostream>
using namespace std;
int main ()
{

    int x , a  , d , i;
	char str;

	while ( cin>>x ){
		a = 0;
		d = 0;

		for (i = 1; i <= x ; i++){

			cin>>str;

			if (str=='A')
				a=a+1 ;

			else
				d=d+1;

		}

		if (a>d)
		cout<< "Anton"<<"\n";
		else if
		 (d>a)	cout<< "Danik"<<"\n";
		 else
		 	cout<< "Friendship"<<"\n";
}
	return  0 ;
	}


#include <iostream>
using namespace std;
int main(){

	unsigned int x , a = 0 , d = 0 ;

	cin>>x;

	char arr ;

	if ( x ){

	for( int i = 1 ; i <= x ; i++ ){

		cin>> arr;

		if (arr=='A'){

			a = a + 1 ;
			}
				else if (arr == 'D' )  {
					d = d + 1 ;
				}
					}

	if ( a > d ){

			cout<<"Anton";

	}
	 else if ( d > a ){

		cout<<"Danik";
		}

		else if (a==d) {
			cout<< "Freindship";
		}

	}
}


#include <iostream>

using namespace std;

int main()
{
    int n,a=0,d=0;
    string g;
    cin>>n>>g;
    for(int i=0;i<n;i++)
    {
        if(g.at(i)=='A')
        a+=1;
        else
        d+=1;

    }
    if(a>d)
        cout<<"Anton ";
    if(d>a)
        cout<<"Danik ";
    else
        cout<<" Friendship" ;

    return 0;
}


#include <iostream>
using namespace std;

int main() {
    int n,suma =0,sumd =0;
    string s;
    cin>>n>>s;
    for (int i =0; i<n;i++)
    {
        if (i == 'D')
            sumd+=1;
        if( i== 'A')
            suma+=1;
    }
   if (suma >sumd)
    cout<<"Anton";
   else if (sumd > suma)
    cout<<"Danik";
   else if (suma ==sumd)
    cout <<"Friendship";
}


#include <iostream>
using namespace std;

int main() {
    int n,suma =0,sumd =0;
    string s;
    cin>>n>>s;
    for (int i =0; i<n;i++)
    {
        if (i == 'D')
            sumd+=1;
        if( i== 'A')
            suma+=1;
    }
   if (suma>sumd)
    cout<<"Anton";
   else if (sumd>suma)
    cout<<"Danik";
   else
    cout <<"Friendship";
}


#include <iostream>
using namespace std;

int main() {
    int n,suma =0,sumd =0;
    string s;
    cin>>n>>s;
    for (int i =0; i<n;i++)
    {
        if (s[i] == 'D')
            sumd+=1;
        if( s[i]== 'A')
            suma+=1;
    }

   if (suma >sumd)
    cout<<"Anton";
   else if (sumd > suma)
    cout<<"Danik";
   else if (suma ==sumd)
    cout <<"Friendship";
}


#include <iostream>
using namespace std;

int main() {
    int n,suma,sumd ;
    string s;
    cin>>n>>s;
    for (int i =0; i<n;i++)
    {
        if (i == 'D')
            sumd+=1;
        if( i== 'A')
            suma+=1;
    }
   if (suma>sumd)
    cout<<"Anton";
   else if (sumd>suma)
    cout<<"Danik";
   else
    cout <<"Friendship";
}


#include <iostream>

using namespace std;

int main()
{
    int n,a=0,d=0;
    string g;
    cin>>n>>g;
    for(int i=0;i<n;i++)
    {
        if(g.at(i)=='A')
        a+=1;
        else
        d+=1;

    }
    if(a>d)
        cout<<"Anton ";
    if(d>a)
        cout<<"Danik ";
    if(a==d)
        cout<<" Friendship" ;

    return 0;
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	string s;
	int c = 0, n;

	cin >> n;
	cin >> s;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c++;
	}
	if(c > s.size()/2) cout << "Anton";
	else if(c < s.size()/2) cout << "Danik";
	else cout << "Friendship";
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	string s;
	int c = 0, n;

	cin >> n;
	cin >> s;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c++;
	}
	if(c == s.size()/2) cout << "Friendship";
	else if(c < s.size()/2) cout << "Danik";
	else cout << "Anton";
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	fast;

	string s;
	int n;

	cin >> n;
	cin >> s;

	int c = n;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c--;
	}
	if(c > s.size()/2) cout << "Danik";
	else if(c < s.size()/2) cout << "Anton";
	else cout << "Friendship";
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	Fast;

	string s;
	int n;

	cin >> n;
	cin >> s;

	int c = n;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c--;
	}
	if(c > s.size()/2) cout << "Danik";
	else if(c < s.size()/2 or c == 0) cout << "Anton";
	else cout << "Friendship";
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	Fast;

	string s;
	int n;

	cin >> n;
	cin >> s;

	int c = n;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c--;
	}
	if(c > s.size()/2 or c == 0) cout << "Danik";
	else if(c < s.size()/2) cout << "Anton";
	else cout << "Friendship";
}


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

#define fs first
#define sc second
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define Fast cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
typedef long long ll;

int main(){
	Fast;

	string s;
	int n;

	cin >> n;
	cin >> s;

	int c = n;

	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A') c--;
	}
	if(c > s.size()/2) cout << "Danik";
	else if(c < s.size()/2) cout << "Anton";
	else cout << "Friendship";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;
    for(int i=0;i<str.length();i++){
        int a=0,d=0;
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else{
        cout<<"Friendship"<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int a=0,d=0;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else{
        cout<<"Friendship"<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int a=0,d=0,n;
    cin>>n;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    //cout<<a<<" "<<d<<endl;
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else if(a==d){
        cout<<"Friendship"<<endl;
    }
    a=0;
    d=0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int a=0,d=0;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    //cout<<a<<" "<<d<<endl;
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else if(a==d){
        cout<<"Friendship"<<endl;
    }
    a=0;
    d=0;
}


#include<bits/stdc++.h>
using namespace std;
inr main(){
    string str;
    cin>>str;
    for(int i=0;i<str.length();i++){
        int a=0,d=0;
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else{
        cout<<"Friendship"<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int a=0,d=0;
    cin>>str;
    for(int i=0;i<str.length();i++){
        if(str[i]=='A'){
            a++;
        }
        else if(str[i]=='D'){
            d++;
        }
    }
    //cout<<a<<" "<<d<<endl;
    if(a>d){
        cout<<"Anton"<<endl;
    }
    else if(d>a){
        cout<<"Danik"<<endl;
    }
    else{
        cout<<"Friendship"<<endl;
    }
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a[2];
    a[0]=0; a[1]=0;
    string str;
    scanf("%d",&n);
    scanf("%s",str);
    for(int i=0;i<n;i++)
    {
        if(str[i]== 'A')
        a[0]+=1;
        else
        a[1]+=1;
    }
    if(a[0]>a[1])
    printf("Anton");
    else if(a[0]<a[1])
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a=0,d=0;
    scanf("%d",&n);
    char str[n];
    for(int i=0;i<=n;i++)
    scanf("%c",&str[i]);
    for(int i=0;i<=n;i++)
    {
        if(str[i]== 'A')
        a=a+1;
        else if(str[i]=='D')
        d=d+1;
    }
    if(a>d)
    printf("Anton");
    else if(a<d)
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a,d;
    a[0]=0; a[1]=0;
    string str;
    scanf("%d",&n);
    scanf("%s",str);
    for(int i=0;i<n;i++)
    {
        if(str[i]== 'A')
        a[0]+=1;
        else
        a[1]+=1;
    }
    if(a[0]>a[1])
    printf("Anton");
    else if(a[0]<a[1])
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a=0,d=0;
    scanf("%d",&n);
    char str[n];
    for(int i=0;i<=n;i++)
    scanf("%c",&str[i]);
    printf("%s\n",str);
    for(int i=0;i<=n;i++)
    {
        if(str[i]== 'A')
        a=a+1;
        else if(str[i]=='D')
        d=d+1;
    }
    printf("%d\t%d\n",a,d);
    if(a>d)
    printf("Anton");
    else if(a<d)
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a=0,d=0;
    string str;
    scanf("%d",&n);
    scanf("%s",str);
    for(int i=0;i<n;i++)
    {
        if(str[i]== 'A')
        a=a+1;
        else
        d=d+1;
    }
    if(a>d)
    printf("Anton");
    else if(a<d)
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a[2];
    a[0]=0; a[1]=0;
    string str;
    scanf("%d",&n);
    scanf("%s",str);
    for(int i=0;i<n;i++)
    {
        if(str[i]== 'A')
        a[0]++;
        else
        a[1]++;
    }
    if(a[0]>a[1])
    printf("Anton");
    else if(a[0]<a[1])
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int main()
{
    int n,a=0,d=0;
    scanf("%d",&n);
    char str[n];
    for(int i=0;i<n;i++)
    scanf("%c",&str[i]);
    for(int i=0;i<n;i++)
    {
        if(str[i]== 'A')
        a=a+1;
        else if(str[i]=='D')
        d=d+1;
    }
    if(a>d)
    printf("Anton");
    else if(a<d)
    printf("Danik");
    else
    printf("Friendship");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    long long count1=0;
    long long count2=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A')
        count1+=1;
        if(s[i]=='D')
        count2+=1;
    }
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Friendship";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    long long count1=0,count2=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int j=0;j<n;j++)
    {
        if(s[j]=='A')
        count1+=1;
        if(s[j]=='D')
        count2+=1;
    }
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Freindship";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    long long count1=0,count2=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int j=0;j<n;j++)
    {
        if(s[j]=='A')
        count1+=1;
        if(s[j]=='D')
        count2+=1;
    }
    cout<<count1<<"\n";
    cout<<count2<<"\n";
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Freindship";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    long long count1,count2;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int j=0;j<n;j++)
    {
        if(s[j]=='A')
        count1+=1;
        if(s[j]=='D')
        count2+=1;
    }
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Freindship";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    long long count1=0,count2=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(int j=0;j<n;j++)
    {
        if(s[j]=='A')
        count1+=1;
        if(s[j]=='D')
        count2+=1;
    }
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Friendship";
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    cin>>s;
    long long count1=0;
    long long count2=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A')
        count1+=1;
        if(s[i]=='D')
        count2+=1;
    }
    if(count1>count2)
    cout<<"Anton";
    else if(count1<count2)
    cout<<"Danik";
    else
    cout<<"Friendship";
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "ANTON";
	}
	else if(da>an){
		cout << "DAVID";
	}
	else if(da==an){
		 cout << "FRIENDSHIP";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	char a[100001];
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main(){
	char a[100001];
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<strlen(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a)*sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "David";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<100000;++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int n,an=0,da=0;
	cin >> n >> a;
	for(int i=0;i<sizeof(a);++i){
		if(a[i]=='A'){
			++an;
		}
		if(a[i]=='D'){
			++da;
		}
	}
	cout << da << an;
	if(an>da){
		cout << "Anton";
	}
	else if(da>an){
		cout << "Danik";
	}
	else if(da==an){
		 cout << "Friendship";
}
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[100];
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if(sum==count)
	cout<<"Friendship"<<endl;
	else
	{
		if(count>sum)
		cout<<"Anton"<<endl;
		else if(sum>count)
		cout<<"Danik"<<endl;

	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[500];
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if((sum==3)&&(count==3))
	cout<<"Friendship"<<endl;
	else
	{
		if(count>sum)
		cout<<"Anton"<<endl;
		else if(sum>count)
		cout<<"Danik"<<endl;

	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[500];
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if(sum==count)
	cout<<"Friendship"<<endl;
	else
	{
		if(count>sum)
		cout<<"Anton"<<endl;
		else if(sum>count)
		cout<<"Danik"<<endl;

	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[100];
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if((sum==3)&&(count==3))
	cout<<"FRIENDSHIP"<<endl;
	else
	{
		if(count>sum)
		cout<<"anton"<<endl;
		else if(sum>count)
		cout<<"danik"<<endl;

	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char s[100];
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if((sum==3)&&(count==3))
	cout<<"Friendship"<<endl;
	else
	{
		if(count>sum)
		cout<<"Anton"<<endl;
		else if(sum>count)
		cout<<"Danik"<<endl;

	}
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	int sum=0,n,count=0,i,j;
	cin>>n;
	cin>>s;
	for(i=0;s[i]!='\0';i++)
	{
		if(s[i]=='A')
		count++;
		else
		sum++;
	}
	if(sum==count)
	cout<<"Friendship"<<endl;
	else
	{
		if(count>sum)
		cout<<"Anton"<<endl;
		else if(sum>count)
		cout<<"Danik"<<endl;

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    string s;
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 'A') {a++;}
        else d++;
    }
    if (a ==  d) cout << "FRIENDSHIP" << endl;
    if (a > d) cout << "AHTOH" << endl;
    if (a < d) cout << "DANIK " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    string s;
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 'A') a++;
        else d++;
    }
    if (a ==  d) cout << "Friendship" << endl;
    if (a > d) cout << "Anton" << endl;
    if (a < d) cout << "Danik " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    string s;
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 'A') {a++;}
        else d++;
    }
    if (a ==  d) cout << "FRIENDSHIP" << endl;
    if (a > d) cout << "ANTON" << endl;
    if (a < d) cout << "DANIK " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    string s;
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 'A') {a++;}
        else d++;
    }
    if (a ==  d) cout << "Friendship" << endl;
    if (a > d) cout << "Anton" << endl;
    if (a < d) cout << "Danik " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char name[n];
    int a = 0;
    int d = 0;
    for (int i = 0; i <= n; i++)
    {
        cin >> name[i];
        if (name[i] == 'A') a++;
        if (name[i] == 'D') d++;
    }
    if (a ==  d) cout << "Friendship" << endl;
    if (a > d) cout << "Anton" << endl;
    if (a < d) cout << "Danik " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    char name[n];
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> name[i];
        if (name[i] == 'A') a++;
        else d++;
    }
    if (a ==  d) cout << "Friendship" << endl;
    if (a > d) cout << "Anton" << endl;
    if (a < d) cout << "Danik " << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,d;
    char name[n];
    cin >> n;
    a = 0;
    d = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> name[i];
        if (name[i] == 'A') a++;
        if (name[i] == 'D') d++;
    }
    if (a ==  d) cout << "Friendship" << endl;
    if (a > d) cout << "Anton" << endl;
    if (a < d) cout << "Danik " << endl;
    return 0;
}


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

int main()
{
	int n,a,d;
	char t;
	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i < n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton"
			break;
		}
		if (d > a) {
			cout << "Danik";
			break;
		}
		else {
			cout << "Friendship";
			break;
		}
	}
	return 0;
}


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

int main()
{

	int n, a, d;
	char t;

	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i <= n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton";
		}
		if (d > a) {
			cout << "Danik";
		}
		else {
			cout << "Friendship";
		}
	}

	return 0;
}


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

int main()
{
	int n,a,d;
	char t;
	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i < n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton";
			break;
		}
		if (d > a) {
			cout << "Danik";
			break;
		}
		else {
			cout << "Friendship";
		}
	}
	return 0;
}


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

int main()
{

	int n, a, d;
	char t;
	cin >> n;

	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i <= n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton" << endl;
		}
		if (d > a) {
			cout << "Danik" << endl;
		}
		if (a = d) {
			cout << "Friendship" << endl;
		}
	}

	return 0;
}


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

int main()
{

	int n;
	string text;
	cin >> n;

	for (int i=0; i <= n; i++) {
		cin >> text;
		if ("A" > "D") {
			cout << "Anton" << endl;
		}
		else if ("D" > "A") {
			cout << "Danik" << endl;
		}
		else {
			cout << "Friendship" << endl;
		}
	}

	// Задача: найти наименьший делитель.

	//	int n;
	//    cin >> n;
	//    for(int i = 2; i<=n; i++){
	//        if(n%i==0){
	//            cout << i << endl;
	//            break;
	//        }
	//    }

	// Задача: перевернуть число, используя while.

	// int a;
	// cin >> a;
	//	while(a !=0){
	//	int x;
	//	x = a % 10;
	//	cout << x;
	//	a = a/10;
	//	}

	// Задача: суммировать цифры числа, используя while.

	// int a;
	// int n = 0;
	// cin >> a;
	// while(a !=0){
	// 	int x;
	// 	x = a % 10;
	// 	n = n + x;
	// 	a = a / 10;
	// }
	// cout << n;

	// Задача: найти

	// int a, b;
	// cin >> a >> b;
	// for(int i = a; i<=b; i++){
	// 	cout << sqrt(i) << ' ';
	// }

	// int a;
	// int b;
	// cin >> a >> b;

	// for(int i = a; i<=b; i++){
	// 	cout << i << ' ';
	// }

	// int n;
	// cin >> n;
	// for(int i = 0; i < n; i++){
	// 	cout<< i << ' ';
	// }

	// int m;
	// int n;
	// cin>>m>>n;
	// cout<<m*n/2<<endl;

	// int n;
	// cin>>n;
	// if(n%2==0 && n!=2){
	// 	cout<<"YES";
	// }
	// else if(n==2){
	// 	cout<<"NO";
	// }
	// else{
	// 	cout<<"NO";
	// }

	return 0;
}


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

int main()
{

	int n, a, d;
	char t;

	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i <= n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton" << endl;
			break;
		}
		if (d > a) {
			cout << "Danik" << endl;
			break;
		}
		else {
			cout << "Friendship" << endl;
			break;
		}
	}

	return 0;
}


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

int main()
{

	int n;
	char text;
	cin >> n;

	for (int i=0; i <= n; i++) {
		cin >> text;
		if ("A" > "D") {
			cout << "Anton" << endl;
		}
		else if ("D" > "A") {
			cout << "Danik" << endl;
		}
		else {
			cout << "Friendship" << endl;
		}
	}

	// Задача: найти наименьший делитель.

	//	int n;
	//    cin >> n;
	//    for(int i = 2; i<=n; i++){
	//        if(n%i==0){
	//            cout << i << endl;
	//            break;
	//        }
	//    }

	// Задача: перевернуть число, используя while.

	// int a;
	// cin >> a;
	//	while(a !=0){
	//	int x;
	//	x = a % 10;
	//	cout << x;
	//	a = a/10;
	//	}

	// Задача: суммировать цифры числа, используя while.

	// int a;
	// int n = 0;
	// cin >> a;
	// while(a !=0){
	// 	int x;
	// 	x = a % 10;
	// 	n = n + x;
	// 	a = a / 10;
	// }
	// cout << n;

	// Задача: найти

	// int a, b;
	// cin >> a >> b;
	// for(int i = a; i<=b; i++){
	// 	cout << sqrt(i) << ' ';
	// }

	// int a;
	// int b;
	// cin >> a >> b;

	// for(int i = a; i<=b; i++){
	// 	cout << i << ' ';
	// }

	// int n;
	// cin >> n;
	// for(int i = 0; i < n; i++){
	// 	cout<< i << ' ';
	// }

	// int m;
	// int n;
	// cin>>m>>n;
	// cout<<m*n/2<<endl;

	// int n;
	// cin>>n;
	// if(n%2==0 && n!=2){
	// 	cout<<"YES";
	// }
	// else if(n==2){
	// 	cout<<"NO";
	// }
	// else{
	// 	cout<<"NO";
	// }

	return 0;
}


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

int main()
{
	int n,a,d;
	char t;
	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i < n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton"
			break;
		}
		if (d > a) {
			cout << "Danik";
			break;
		}
		else {
			cout << "Friendship";
		}
	}
	return 0;
}


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

int main()
{

	int n, a, d;
	char t;

	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i < n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton";
		}
		if (d > a) {
			cout << "Danik";
		}
		else {
			cout << "Friendship";
		}
	}

	return 0;
}


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

int main()
{

	int n;
	string text;
	cin >> n;
	cin >> text;

	for (int i=0; i <= n; i++) {
		if ("A" > "D") {
			cout << "Anton" << endl;
		}
		else if ("D" > "A") {
			cout << "Danik" << endl;
		}
		else {
			cout << "Friendship" << endl;
		}
	}

	return 0;

}


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

int main()
{

	int n, a, d;
	char t;

	while (cin >> n) {
		a = 0;
		d = 0;
		for (int i = 0; i <= n; i++) {
			cin >> t;
			if (t == 'A') {
				a++;
			}
			if (t == 'D'){
				d++;
			}
		}
		if (a > d) {
			cout << "Anton" << endl;
			break;
		}
		if (d > a) {
			cout << "Danik" << endl;
			break;
		}
		if (a = d && d = a) {
			cout << "Friendship" << endl;
			break;
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+10;
int cnt[maxn<<1],a[maxn],ans[maxn];
int n,m,k,len,now;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
struct node{
	int l,r,id,bl;
}q[maxn];
inline int cmp(node x,node y){
	return (x.bl^y.bl)?(x.bl<y.bl):((x.bl&1)?(x.r<y.r):(x.r>y.r));
}
int main(){
	n=read(),m=read(),k=read();
	len=sqrt(n)+1;
	for(int i=1;i<=n;i++){
		a[i]=read();
		a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++){
		q[i].l=read();
		q[i].r=read();
		q[i].id=i;
		q[i].bl=q[i].l/len+1;
	}
	sort(q+1,q+1+m,cmp);
	int l=1,r=0;
	for(int i=1;i<=m;i++){
		while(l<q[i].l-1)now-=cnt[a[l]^k],cnt[a[l++]]--;
		while(l>q[i].l-1)now+=cnt[a[--l]^k],cnt[a[l]]++;
		while(r<q[i].r)now+=cnt[a[++r]^k],cnt[a[r]]++;
		while(r>q[i].r)now-=cnt[a[r]^k],cnt[a[r--]]--;
		ans[q[i].id]=now;
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 100020 , Val = 5000020;
int n,m,k,a[N],s[N];
int size,cnt[Val];
long long ans[N],tot;
struct query{int l,r,id;}q[N];
inline int read(void)
{
    int x = 0 , w = 0;char ch;
    while ( !isdigit(ch) ) w |= ch=='-' , ch = getchar();
    while ( isdigit(ch) ) x = x*10 + ch-48 , ch = getchar();
    return w ? -x : x;
}
inline void input(void)
{
    n = read() , m = read() , k = read();
    for (int i=1;i<=n;i++)
        a[i] = read() , s[i] = s[i-1] ^ a[i];
    for (int i=1;i<=m;i++)
        q[i].l = read() , q[i].r = read() , q[i].id = i;
}
inline void insert(int p)
{
    tot += cnt[ k ^ s[p] ];
    cnt[ s[p] ] ++;
}
inline void remove(int p)
{
    cnt[ s[p] ] --;
    tot -= cnt[ k ^ s[p] ];
}
inline bool compare(query p1,query p2)
{
    if ( (p1.l/size) ^ (p2.l/size) )
        return p1.l < p2.l;
    else if ( (p1.l/size) & 1 )
        return p1.r < p2.r ;
    else return p1.r > p2.r ;
}
inline void CaptainMo(void)
{
    size = n*1.0/(sqrt(m*1.0*2/3));
    sort( q+1 , q+m+1 , compare );
    int l = 1 , r = 0;
    cnt[0] = 0;
    for (int i=1;i<=m;i++)
    {
        int ql = q[i].l-1 , qr = q[i].r;
        while ( l < ql ) remove(l++);
        while ( l > ql ) insert(--l);
        while ( r < qr ) insert(++r);
        while ( r > qr ) remove(r--);
        ans[ q[i].id ] = tot;
    }
}
signed main(void)
{
    //freopen("2011.in","r",stdin);
    //freopen("2011.out","w",stdout);
    input();
    CaptainMo();
    for (int i=1;i<=m;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define R register
#define U unsigned
#define S short
#define qwq printf("qwq\n")

const int N = 1e5 + 5;

int n, m, k, len, res;
int l = 1, r = 0;
int a[N], b[N], ans[N], cnt[N * 10];

struct node {
	int l, r, pos, id;
} q[N];

inline bool cmp (node x, node y) {
	return x.pos == y.pos?x.r < y.r:x.pos < y.pos;
}

inline void add (int x) {
	res += cnt[a[x] ^ k];
	cnt[a[x]]++;//手动模拟一下
}

inline void sub (int x) {
	cnt[a[x]]--;
	res -= cnt[a[x] ^ k];
}

int main () {
	scanf("%d%d%d", &n, &m, &k);
	len = sqrt(n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] = a[i] ^ a[i - 1];//憋忘了处理的是前缀和
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &q[i].l, &q[i].r);
		q[i].l--;//要考虑cnt[0]的情况
		q[i].id = i, q[i].pos = (q[i].l - 1) / len + 1;
	}
	sort(q + 1, q + m + 1, cmp);
	for (int i = 1; i <= m; i++) {
		while (q[i].l < l) add(--l);
		while (q[i].r > r) add(++r);
		while (q[i].l > l) sub(l++);
		while (q[i].r < r) sub(r--);
		ans[q[i].id] = res;
	}
	for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
	return 0;
}/*关键思路:一段区间的xor和等于b[l-1]^b[r]
所以问题就转化成了求[l,r]中有多少个数对满足b[x-1]^b[y]=k
这不就很简单了吗...*/


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=510001;
int n,m,k,qu;
int a[maxn];
struct node{
	int l,r,pl;
}h[maxn];
bool cmp(node a,node b){
	if(a.l/qu==b.l/qu){
		if((a.l/qu)%2==1) return a.l<b.l;
		return a.r>b.r;
	}
	return a.l/qu<b.l/qu;
}
long long book[maxn],as[maxn];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	qu=sqrt(n)*5/3;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&h[i].l,&h[i].r);
		h[i].l--;
		h[i].pl=i;
	}
	book[0]=1;
	sort(h+1,h+1+m,cmp);
	int L=0,R=0;
	long long sum=0;
	for(int i=1;i<=m;i++){
		while(L>h[i].l){
			L--;
			sum+=book[a[L]^k];
			book[a[L]]++;
		}
		while(L<h[i].l){
			book[a[L]]--;
			sum-=book[a[L]^k];
			L++;
		}
		while(R<h[i].r){
			R++;
			sum+=book[a[R]^k];
			book[a[R]]++;
		}
		while(R>h[i].r){
			book[a[R]]--;
			sum-=book[a[R]^k];
			R--;
		}
		as[h[i].pl]=sum;
	}
	for(int i=1;i<=m;i++) printf("%lld\n",as[i]);
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
const int N=1e6+8;
LL pos[N],n,m,a[N],res;
struct node {
	LL l,r,k;
} fu[N];
LL ans[N],cnt[N],k;
bool cmd(node a,node b) {
	return pos[a.l]==pos[b.l]?a.r<b.r:pos[a.l]<pos[b.l];
}
void add(int i) {
	res+=cnt[a[i]^k];
	cnt[a[i]]++;

}
void sub(int i) {
	cnt[a[i]]--;
	res-=cnt[a[i]^k];
}
int main() {
	scanf("%lld%lld%lld",&n,&m,&k);
	int siz=sqrt(n);cnt[0]=1;
	for(int i=1; i<=n; i++) {
		scanf("%lld",&a[i]);
		a[i]=a[i]^a[i-1];
		pos[i]=i/siz;
	}
	for(int i=1; i<=m; i++) {
		scanf("%lld%lld",&fu[i].l,&fu[i].r);
		fu[i].k=i;
		fu[i].l--;
	}
	sort(fu+1,fu+m+1,cmd);
	LL l=0,r=0;
	for(int i=1; i<=m; i++) {
		for (;l<fu[i].l;l++) sub(l);
        for (;l>fu[i].l;l--) add(l-1);
        for (;r<fu[i].r;r++) add(r+1);
        for (;r>fu[i].r;r--) sub(r);
		ans[fu[i].k]=res;
	}
	for(int i=1; i<=m; i++) printf("%lld\n",ans[i]);
	return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1001001;
int n,m,k,qu;
int a[maxn];
struct node{
	int l,r,pl;
}h[maxn];
bool cmp(node a,node b){
	if(a.l/qu==b.l/qu){
		if((a.l/qu)%2==1) return a.l<b.l;
		return a.r>b.r;
	}
	return a.l/qu<b.l<qu;
}
long long book[maxn],as[maxn];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	qu=sqrt(n)*5/3;
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&h[i].l,&h[i].r);
		h[i].l--;
		h[i].pl=i;
	}
	book[0]=1;
	sort(h+1,h+1+m,cmp);
	int L=0,R=0;
	long long sum=0;
	for(int i=1;i<=m;i++){
		while(L>h[i].l){
			L--;
			sum+=book[a[L]^k];
			book[a[L]]++;
		}
		while(L<h[i].l){
			book[a[L]]--;
			sum-=book[a[L]^k];
			L++;
		}
		while(R<h[i].r){
			R++;
			sum+=book[a[R]^k];
			book[a[R]]++;
		}
		while(R>h[i].r){
			book[a[R]]--;
			sum-=book[a[R]^k];
			R--;
		}
		as[h[i].pl]=sum;
	}
	for(int i=1;i<=m;i++) printf("%lld\n",as[i]);
	return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#define int long long
using namespace std;
const int maxn=1<<20-1;
int n,m,k,pos,tong[maxn];
int a[maxn],l,r,sum,ans[maxn];
struct node{
	int l,r,id;
}s[maxn];
int read()
{
	int x=0,f=1;
	char c;
	c=getchar();
	while (c<'0'||c>'9')
	{
		if (c=='-')f=-1;
		c=getchar();
	}
	while (c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
bool cmp(node a,node b)
{
	if (a.l/pos!=b.l/pos)return a.l<b.l;
	else
	{
		if ((a.r/pos)%2)return a.r<b.r;
		else return a.r>b.r;
	}
}
signed main()
{
	n=read();
	m=read();
	k=read();
	pos=sqrt(n);
	for (int i=1;i<=n;i++)
	{
		a[i]=read();
		a[i]^=a[i-1];
	}
	for (int i=1;i<=m;i++)
	{
		s[i].l=read();
		s[i].l--;
		s[i].r=read();
		s[i].id=i;
	}
	sort(s+1,s+m+1,cmp);
	l=1;
	for (int i=1;i<=m;i++)
	{
		while (l<s[i].l)
		{
			tong[a[l]]--;
			sum-=tong[k^a[l]];
			l++;
		}
		while (l>s[i].l)
		{
			l--;
			sum+=tong[k^a[l]];
			tong[a[l]]++;
		}
		while (r<s[i].r)
		{
			r++;
			sum+=tong[k^a[r]];
			tong[a[r]]++;
		}
		while (r>s[i].r)
		{
			tong[a[r]]--;
			sum-=tong[k^a[r]];
			r--;
		}
		ans[s[i].id]=sum;
	}
	for (int i=1;i<=m;i++)printf("%lld\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=100005;typedef long long ll;
struct node{
    int l,r;
    int Rk;
    ll ans;
}s[N];

int n,m,K;
int col[N];
int a[N];//异或前缀
ll happen[N*10]={0};
ll ans=0;
int l,r;
int u;
int b[N];
bool cmp(node x,node y){
    if(b[x.l]==b[y.l]) return x.r<y.r;
    return x.l<y.l;
}
bool kmp(node x,node y){
    return x.Rk<y.Rk;
}
int main(){
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> K){
        memset(happen,0,sizeof(happen));
        u=sqrt(n);
        for(int i=1;i<=n;i++) b[i]=(i/u)+1;
        for(int i=1;i<=n;i++){
            cin >> col[i];
            a[i]=a[i-1]^col[i];
        }
        a[0]=0;
        for(int i=1;i<=m;i++){
            cin >> s[i].l >> s[i].r;
            s[i].Rk=i;
        }
        l=1,r=0,happen[0]=1;
        sort(s+1,s+m+1,cmp);
        ans=0;
        for(int i=1;i<=m;i++){
                while(l<s[i].l){
                    happen[a[l-1]]--;
                    ans-=happen[K^a[l-1]];
                    l++;
                }
                while(l>s[i].l){
                    l--;
                    ans+=happen[K^a[l-1]];
                    happen[a[l-1]]++;
                }
                while(r<s[i].r){
                    r++;
                    ans+=happen[K^a[r]];
                    happen[a[r]]++;
                }
                while(r>s[i].r){
                    happen[a[r]]--;
                    ans-=happen[K^a[r]];
                    r--;
                }
            s[i].ans=ans;
        }
        sort(s+1,s+m+1,kmp);
        for(int i=1;i<=m;i++){
            cout << s[i].ans << endl;
        }
    }
    return 0;
}


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

const int N = 100000 + 7, A = 2000000 + 7;

int n, m, k, s;
int a[N], bel[N];
int cnt[A];
long long res[N], now;
struct str {
	int l, r, i;
} e[N];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	s = sqrt(n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i),
		a[i] ^= a[i - 1],
		bel[i] = bel[i - 1] + (i % s == 1);
	for (int i = 1; i <= m; ++i)
		scanf("%d%d", &e[i].l, &e[i].r),
		--e[i].l, e[i].i = i;
	sort(e + 1, e + m + 1, [](str a, str b) -> int {
	    if (a.l == b.l && a.r == b.r) return 1;
		if (bel[a.l] != bel[b.l]) return bel[a.l] < bel[b.l];
		return (a.r < b.r) ^ (bel[a.l] & 1);
	});

	cnt[0] = 1;
	for (int i = 1, l = 0, r = 0; i <= m; ++i) {
		while (l > e[i].l) now += 1ll * cnt[a[--l] ^ k], ++cnt[a[l]];
		while (r < e[i].r) now += 1ll * cnt[a[++r] ^ k], ++cnt[a[r]];
		while (l < e[i].l) --cnt[a[l]], now -= 1ll * cnt[a[l++] ^ k];
		while (r > e[i].r) --cnt[a[r]], now -= 1ll * cnt[a[r--] ^ k];
		res[e[i].i] = now;
	}

	for (int i = 1; i <= m; ++i)
		printf("%lld\n", res[i]);
	return 0;
}


#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define g getchar()
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
const int N=1<<20|10;
template<class o>void qr(o&x) {
	char c=g;int f=1;x=0;
	while(!isdigit(c)){if(c=='-')f=-1;c=g;}
	while(isdigit(c))x=x*10+c-'0',c=g;
	x*=f;
}
template<class o>void write(o x) {
	if(x/10)write(x/10);
	putchar(x%10+'0');
}
template<class o>void pri(o x) {
	if(x<0)x=-x,putchar('-');
	write(x);puts("");
}

int n,m,k,c[N],a[N],b[N],l,r,t;
ll ans[N],sum[N],tmp;

struct node {
	int l,r,x;
	bool operator <(node b) const {
		return l/t==b.l/t?((l/t)&1?r<b.r:r>b.r):l<b.l;
	}
}Q[N];

int main() {
	qr(n); qr(m); qr(k); a[0]++;
	for(int i=1;i<=n;i++) {
		qr(c[i]);
		c[i]^=c[i-1];
		sum[i]=sum[i-1]+a[c[i]^k];
		a[c[i]]++;
	}
	memset(a,0,sizeof a);t=sqrt(n);
	for(int i=1,x,y;i<=m;i++) {
		qr(x); qr(y);
		Q[i]=(node){x-2,y,i};
		ans[i]=sum[y];
	}
	sort(Q+1,Q+m+1);
	l=r=tmp=0; a[0]=b[0]=1;
	for(int i=1;i<=m;i++) {
		int x=Q[i].l,y=Q[i].r,id=Q[i].x;
		if(x==-1) continue;
		while(x<l) tmp-=b[c[l]^k]-a[c[l]^k],a[c[l--]]--;
		while(r<y) b[c[++r]]++,tmp+=a[c[r]^k];
		while(l<x) a[c[++l]]++,tmp+=b[c[l]^k]-a[c[l]^k];
		while(y<r) tmp-=a[c[r]^k],b[c[r--]]--;
		ans[id]-=tmp;//a桶存[0,l],b桶存[0,r]
	}
	for(int i=1;i<=m;i++) pri(ans[i]);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>
#define N 1000005
using namespace std;

int n, m, k;
long long Ans = 0;
int sum[N], val[N];
long long pos[N], flag[N], ans[N];
struct node{
	int l, r, id;
}Q[N];

bool tmp(node a, node b)
{
	if (pos[a.l] == pos[b.l])
		return a.r < b.r;
	else return pos[a.l] < pos[b.l];
}

void add(int x)
{
	Ans += flag[sum[x] ^ k];
	flag[sum[x]]++;
}

void del(int x)
{
	flag[sum[x]]--;
	Ans -= flag[sum[x] ^ k];
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	int t = sqrt(n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &val[i]);
		sum[i] = sum[i - 1] ^ val[i];
		pos[i] = i / t;
	}
	for (int i = 1; i <= m; ++i)
	{
		scanf("%d %d", &Q[i].l, &Q[i].r);
		Q[i].id = i;
	}
	flag[0] = 1;
	sort(Q + 1, Q + m + 1, tmp);
	int l = 1, r = 0;
	for (int i = 1; i <= m; ++i)
	{
		int p = Q[i].l, q = Q[i].r;
		while (l < p)
		{
			del(l - 1);
			l++;
		}
		while (l > p)
		{
			l--;
			add(l - 1);
		}
		while (r > q)
		{
			del(r);
			r--;
		}
		while (r < q)
		{
			r++;
			add(r);
		}
		ans[Q[i].id] = Ans;
	}
	for (int i = 1; i <= m; ++i)
		printf("%lld\n", ans[i]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int n,m,k,a[200005],t,buc[200005],s[200005];
int head,tail;
long long cnt[2000006],now,ans[200005];
struct node
{
	int l,r,id;
} q[200005];
bool cmp(node a,node b)
{
	if(buc[a.l]==buc[b.l]) return a.r<b.r;
	return buc[a.l]<buc[b.l];
}
void del(int x)
{
	cnt[s[x]]--;
	now-=cnt[s[x]^k];
}
void add(int x)
{
	now+=cnt[s[x]^k];
	cnt[s[x]]++;
}
int main()
{
	n=read();
	m=read();
	k=read();
	for(int i=1;i<=n;i++) s[i]=read();
	for(int i=1;i<=n;i++) s[i]=s[i-1]^s[i];
	t=sqrt(t);
	if(t*t<n) t++;
	for(int i=1;i<=t;i++)
	{
		for(int j=(i-1)*t+1;j<=min(n,i*t);j++)
		{
			buc[j]=i;
		}
	}
	for(int i=1;i<=m;i++)
	{
		q[i].l=read();
		q[i].r=read();
		q[i].l--;
		q[i].id=i;
	}
	sort(q+1,q+m+1,cmp);
	//cnt[0]=1;
	tail=-1;
	head=0;
	for(int i=1;i<=m;i++)
	{
		int ql=q[i].l,qr=q[i].r;
		while(head<ql) del(head++);
		while(head>ql) add(--head);
		while(tail>qr) del(tail--);
		while(tail<qr) add(++tail);
		ans[q[i].id]=now;
	}
	for(int i=1;i<=m;i++) printf("%lld\n",ans[i]);
	return 0;
}


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

const int mm=2000000;
int n,m,k;
int a[mm];
int cnt[mm];
int T;
int ans=0;

struct note
{
    int id;
    int l;int r;
    int b;
    int ans=0;
}q[mm];
int u[mm];
//bool cmp(note &a,note &b)
//{
  //  if(a.b==b.b){return a.r<b.r;}
   // else{return a.l<b.l;}
//}
inline bool cmp(note a,note b){
    if (a.b!=b.b) return a.l<b.l;
    if ((a.l)&1) return a.r<b.r; return a.r>b.r;
}

bool cmpid(note &a,note &b)
{
    return a.id<b.id;
}

inline void add(int x)
{
    ans+=cnt[a[x]^k];
    cnt[a[x]]++;
}

inline void del(int x)
{
    cnt[a[x]]--;
    ans-=cnt[a[x]^k];
}

int len=0;

signed main()
{
    freopen("in", "r", stdin), freopen("out", "w", stdout);
    scanf("%d%d%d",&n,&m,&k);
    len=(int)sqrt(n);
    for(int i=1;i<=n;i++){scanf("%d",&a[i]);a[i]=a[i]^a[i-1];}
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].id=i;
        //q[i].l--;
        q[i].b=(q[i].l-1)/len+1;
    }
    sort(q+1,q+1+m,cmp);
    int l=1,r=0;
    cnt[0]++;
    //cnt[a[1]]++;
    for(int i=1;i<=m;i++)
    {

        while(l<q[i].l){
            del(l-1);
            l++;
        }
        while(l>q[i].l){
            l--;
            add(l-1);
        }
        while(r<q[i].r){
            r++;
            add(r);
        }
        while(r>q[i].r){
            del(r);
            r--;
        }
        q[i].ans=ans;
        u[q[i].id]=ans;
    }

   // sort(q+1,q+1+m,cmpid);
    for(int i=1;i<=m;i++)
    {
        //cout<<q[i].ans<<endl;
        printf("%d\n",u[i]);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
//#define getchar() (p1==p2 and (p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
#define MN 100005
inline void read(int &a){
    a=0;
    register char c=getchar();
    while(c>57 or c<48)c=getchar();
    while(47<c and c<58){
        a=a*10+c-48;
        c=getchar();
    }
}
struct que{
    int l,r,area,id;
}w[MN];
int a[MN],ans,vis[1<<21],n,m,k,block,ANS[MN];
bool cmp(que a,que b){
    return a.area!=b.area?a.l<b.l:(a.area&1?(a.r<b.r):(a.r>b.r));
}
void del(int x){vis[a[x]]--;ans-=vis[a[x]^k];}
void add(int x){vis[a[x]]++;ans+=vis[a[x]^k];}
int main(){
    read(n);read(m);read(k);
    block=sqrt(n);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        a[i]^=a[i-1];
    }
    for(int i=1;i<=m;++i){
        read(w[i].l);read(w[i].r);
        w[i].l--;
        w[i].area=w[i].l/block;w[i].id=i;
    }
    sort(w+1,w+1+m,cmp);
    int l=1,r=0;
    for(int i=1;i<=m;++i){
        while(l>w[i].l)add(--l);
        while(l<w[i].l)del(l++);
        while(r<w[i].r)add(++r);
        while(r>w[i].r)del(r--);
        ANS[w[i].id]=ans;
    }
    for(int i=1;i<=m;++i)printf("%d\n",ANS[i]);
    return 0;
}


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

using namespace std;

typedef long long ll;
const int MAXN = 100010;

int n, m, k, a[MAXN], pos[MAXN], pre[MAXN];

struct node{
	int l, r, ind;
	bool operator<(const node &o)const{return pos[l]^pos[o.l]?pos[l]<pos[o.l]:pos[l]&1?r<o.r:r>o.r;}
}b[MAXN];

int l = 1, r = 0;
ll res = 0, t[3000010], ans[MAXN];

inline void add(int x)
{
	res += t[pre[x]^k];
	++t[pre[x]];
}
inline void del(int x)
{
	--t[pre[x]];
	res -= t[pre[x]^k];
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	int len = n/sqrt(m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre[i] = pre[i-1] ^ a[i];
		pos[i] = (i-1)/len+1;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&b[i].l,&b[i].r);
		b[i].ind = i;
		--b[i].l;
	}
	sort(b+1, b+m+1);
	for(int i=1;i<=m;i++)
	{
		while(l < b[i].l) del(l++);
		while(l > b[i].l) add(--l);
		while(r < b[i].r) add(++r);
		while(r > b[i].r) del(r--);
		ans[b[i].ind] = res;
	}
	for(int i=1;i<=m;i++)
		printf("%lld\n",ans[i]);
	return 0;
}
#include <algorithm>
#include <iostream>

using namespace std;

typedef long long ll;
const int MAXN = 100010;

int n, m, k, a[MAXN], pos[MAXN], pre[MAXN];

struct node{
	int l, r, ind;
	bool operator<(const node &o)const{return pos[l]^pos[o.l]?pos[l]<pos[o.l]:pos[l]&1?r<o.r:r>o.r;}
}b[MAXN];

int l = 1, r = 0;
ll res = 0, t[20000010], ans[MAXN];

inline void add(int x)
{
	res += t[pre[x]^k];
	++t[pre[x]];
}
inline void del(int x)
{
	--t[pre[x]];
	res -= t[pre[x]^k];
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	int len = n/sqrt(m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		pre[i] = pre[i-1] ^ a[i];
		pos[i] = (i-1)/len+1;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&b[i].l,&b[i].r);
		b[i].ind = i;
		--b[i].l;
	}
	sort(b+1, b+m+1);
	for(int i=1;i<=m;i++)
	{
		while(l < b[i].l) del(l++);
		while(l > b[i].l) add(--l);
		while(r < b[i].r) add(++r);
		while(r > b[i].r) del(r--);
		ans[b[i].ind] = res;
	}
	for(int i=1;i<=m;i++)
		printf("%lld\n",ans[i]);
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e6 + 5;
int n,m,k,ku;
int ans[maxn],cnt[1048576],tot,l[maxn],r[maxn],id[maxn],a[maxn],s[maxn];
bool cmp(int i,int j)
{
	if(l[i] / ku == l[j] / ku) return r[i]<r[j];
	return l[i]<l[j];
}
void add(int x)
{
	tot+=cnt[s[x] xor k];
	cnt[s[x]]++;
}
void erase(int x)
{
	cnt[s[x]]--;
	tot-=cnt[s[x] xor k];
}
signed main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		s[i]=s[i-1] xor a[i];
	}
	for(int i=0;i<m;i++)
	{
		scanf("%lld%lld",&l[i],&r[i]);
		l[i]--;
		id[i]=i;
	}
	ku=sqrt(n);
	sort(id,id+m,cmp);
	int s=1,t=0;
	for(int j=0;j<m;j++)
	{
		int i=id[j];
		while(t<r[i]) add(++t);
		while(s>l[i]) add(--s);
		while(s<l[i]) erase(s++);
		while(t>r[i]) erase(t--);
		ans[i]=tot;
	}
	for(int i=0;i<m;i++)
	{
		cout<<ans[i]<<endl;
	}
}


//Program written by Liu Zhaozhou ~~~
#include <bits/stdc++.h>

#define lowbit(x) x & -x
#pragma GCC optimize("Ofast,inline")

using namespace std;

namespace Base {
    inline char gc(void)
    {
        static char buf[100000], *p1 = buf, *p2 = buf;
        return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
    }

    #define gc() getchar()

    template <class T> inline void read(T &x)
    {
        T flag = (T) 1; x = 0; static char ch = gc();
        for (; ch > '9' || ch < '0'; ch = gc())
            flag = ch == '-' ? -1 : 1;
        for (; ch >= '0' && ch <= '9'; ch = gc())
            x = (x << 1) + (x << 3) + (ch & 15);
        x *= flag; return;
    }

    inline void readstr(string&x) {
        x = ""; static char ch;
        while (isspace(ch = gc()));
        while (x += ch, !isspace(ch = gc()));
    }

    inline void readstr(char *s) {
        do *s = gc(); while ((*s == ' ') || (*s == '\n') || (*s == '\r'));
        do *(++s) = gc(); while ((~*s) && (*s != ' ') && (*s != '\n') && (*s != '\r'));
        *s = 0; return;
    }

    inline void printstr(string x, int num = 0, char ch = '\n') {
        for (int i = num; i < x.size(); ++i)
            putchar(x[i]); putchar(ch);
    }

    inline void readch(char&x) { while (isspace(x = gc())); }

    char pf[100000], *o1 = pf, *o2 = pf + 100000;
    #define ot(x) (o1 == o2 ? fwrite(pf, 1, 100000, stdout), *(o1 = pf) ++= x : *o1 ++= x)
    template <class T>
    inline void println(T x, char c = '\n') {
        if (x < 0) ot(45), x = -x;
        static char s[15], *b; b = s;
        if (!x) *b ++= 48;
        for (; x; * b ++= x % 10 + 48, x /= 10);
        for (; b-- != s; ot(*b)); ot(c);
    }

    template <class T> inline void write(T x) {
        if (x < 0) putchar('-'), x = -x;
        if (x > 9) write(x / 10);
        putchar(x % 10 + '0'); return;
    }

    template <class T> inline void writeln(T x) { write(x); puts(""); }
    template <class T> inline void writeln(T x, char c) { write(x); putchar(c); }
    template <class T> inline void writeln(char c, T x) { putchar(c); write(x); }

    template <class T> inline void chkmax(T &x, const T y) { x > y ? x = x : x = y; }
    template <class T> inline void chkmin(T &x, const T y) { x < y ? x = x : x = y; }
    template <class T> inline T max(const T&x, const T&y, const T&z) {
        return x > y ? (x > z ? x : z) : (y > z ? y : z);
    }

    typedef long long ll;
    typedef unsigned long long ull;
    typedef long double ld;

    #define Ms(arr, opt) memset(arr, opt, sizeof(arr))
    #define Mp(x, y) make_pair(x, y)

    inline void file(string str) {
        freopen((str + ".in").c_str(), "r", stdin);
        freopen((str + ".out").c_str(), "w", stdout);
    }
}

using namespace Base;

const int Maxn = 100005, Maxs = 3000005;

int n, k, m, a[Maxn], bel[Maxn], block;
struct Block {
    int l, r, idx;
    inline bool operator < (const Block&rhs)
    const { return bel[l] == bel[rhs.l] ? (bel[l]&1)?r<rhs.r:r>rhs.r: l < rhs.l; }
} q[Maxn];

ll sum[Maxs], ans[Maxn], ret = 0ll;
inline void add(int x) { ret += sum[k ^ a[x]]; sum[a[x]]++; }
inline void del(int x) { sum[a[x]]--; ret -= sum[a[x] ^ k]; }

signed main(void) {
//  file("");
    read(n), read(m), read(k); block = (int) sqrt(n);
    for (int i = 1; i <= n; i++)
        read(a[i]), bel[i] = (i - 1) / block + 1, a[i] = a[i - 1] ^ a[i];
    for (int i = 1; i <= m; i++)
        read(q[i].l), read(q[i].r), q[i].l--, q[i].idx = i;
    sort(q + 1, q + m + 1); int l = 0, r = 0; sum[0] = 1;
    for (int i = 1; i <= m; i++) {
		while (r < q[i].r) add(++r);
		while (l > q[i].l) add(--l);
        while (l < q[i].l) del(l++);
        while (r > q[i].r) del(r--);
        ans[q[i].idx] = ret;
    } for (int i = 1; i <= m; i++) writeln(ans[i]);
//  fwrite(pf, 1, o1 - pf, stdout);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define R register
#define U unsigned
#define S short
#define qwq printf("qwq\n")

const int N = 1e5 + 5;

int n, m, k, len, res;
int l = 1, r = 0;
int a[N], b[N], ans[N], cnt[N * 10];

struct node {
	int l, r, pos, id;
} q[N];

inline bool cmp (node x, node y) {
	return x.pos == y.pos?x.r < y.r:x.pos < y.pos;
}

/*inline bool cmp(node c,node d){
	if (bl[c.l]!=bl[d.l]) return c.l<d.l;
	return c.r < d.r;
}*/

inline void add (int x) {
	res += cnt[a[x] ^ k];
	cnt[a[x]]++;//手动模拟
}

inline void sub (int x) {
	cnt[a[x]]--;
	res -= cnt[a[x] ^ k];
}

int main () {
	//freopen("xor.in", "r", stdin);
	//freopen("xor.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &k);
	len = sqrt(n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] = a[i] ^ a[i - 1];//憋忘了处理的是前缀和
		bl[i] = (i - 1) / len + 1;
	}
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &q[i].l, &q[i].r);
		q[i].l--;//要考虑a[x]==0的情况
		q[i].id = i, q[i].pos = (q[i].l - 1) / len + 1;
	}
	sort(q + 1, q + m + 1, cmp);
	//for (int i = 1; i <= m; i++) printf("%d %d %d\n", q[i].l, q[i].r, q[i].id);
	for (int i = 1; i <= m; i++) {
		while (q[i].l < l) add(--l);
		while (q[i].r > r) add(++r);
		while (q[i].l > l) sub(l++);
		while (q[i].r < r) sub(r--);
		ans[q[i].id] = res;
		//printf("%d %d\n", res, q[i].id);
	}
	for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
	return 0;
}/*关键思路:一段区间的xor和等于b[l-1]^b[r]
所以问题就转化成了求[l,r]中有多少个数对满足b[x-1]^b[y]=k
这不就很简单了吗...*/


#include<bits/stdc++.h>
using namespace std;
long long n,m,k,a[1000005],block,s,g[1000005],l=1,r;
long long ans[1000005],f[1000005],sum;
struct node{
	long long l,r,i;
}b[1000005];
bool cmp(node a,node b)
{
	return g[a.l]^g[b.l]?g[a.l]<g[b.l]:(g[a.l]&1?a.r<b.r:a.r>b.r);
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(long long i=1;i<=n;i++)
    	scanf("%lld",&a[i]),a[i]^=a[i-1];
    block=sqrt(n);
    s=n/block;
    if(n%block)s++;
    for(long long i=1;i<=n;i++)
    	g[i]=(i-1)/block+1;
    for(long long i=1;i<=m;i++)
    	scanf("%lld%lld",&b[i].l,&b[i].r),b[i].i=i,b[i].l--;
    sort(b+1,b+1+m,cmp);
    for(long long i=1;i<=m;i++)
    {
    	while(l<b[i].l)f[a[l]]--,sum-=f[a[l]^k],l++;
    	while(l>b[i].l)l--,sum+=f[a[l]^k],f[a[l]]++;
    	while(r<b[i].r)r++,sum+=f[a[r]^k],f[a[r]]++;
    	while(r>b[i].r)f[a[r]]--,sum-=f[a[r]^k],r--;
    	ans[b[i].i]=sum;
	}
	for(long long i=1;i<=m;i++)
		printf("%lld\n",ans[i]);
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 1e6 + 5;
ll ans[maxn],cnt[maxn],a[maxn],belong[maxn];
int l = 1,r,now;
int n,m,k;
void add(int x){
	now += cnt[a[x] ^ k];
	cnt[a[x]]++;
}
void del(int x){
	cnt[a[x]]--;
	now -= cnt[a[x] ^ k];
}
struct Query{
	int l,r,id;
}q[maxn];
bool cmp(Query a,Query b){
	return (belong[a.l] ^ belong[b.l]) ? belong[a.l] < belong[b.l] : ((belong[a.l] & 1) ? a.r < b.r : a.r > b.r);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 1; i <= ceil((double)n/sqrt(n)); i++)
        for(int j = (i - 1) * sqrt(n) + 1; j <= i * sqrt(n); j++)
            belong[j] = i;
	for(int i = 1; i <= n; i++){
		scanf("%lld",&a[i]);
		a[i] ^= a[i - 1];
	}
	for(int i = 1; i <= m; i++){
		scanf("%d%d",&q[i].l,&q[i].r);
		q[i].id = i;
	}
	sort(q + 1,q + m + 1,cmp);
	cnt[0] = 1;
	for(int i = 1; i <= m; i++){
		while (l < q[i].l) { del(l - 1); ++l; }
        while (l > q[i].l) { l--, add(l - 1); }
		// while(l < q[i].l)del(l++);//l右移
        // while(l > q[i].l)add(--l);//l左移
        while(r < q[i].r)add(++r);//r右移
        while(r > q[i].r)del(r--);//r左移
		ans[q[i].id] = now;
	}
	for(int i = 1; i <= m; i++)
		printf("%lld\n",ans[i]);
	return 0;
}


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

const int N = 1000000 + 10;

int n, m, k, a[N], sum[N];
struct Ques{ int l, r, id, pos; } q[N];
int L, R, block, cnt[N], res, ans[N];

bool cmp(Ques x, Ques y){
	if(x.pos == y.pos) return x.pos & 1 ? x.r < y.r : x.r > y.r;
	return x.l < y.l;
}
void add(int x){ res += cnt[k ^ x]; cnt[x] ++; }
void del(int x){ cnt[x] --; res -= cnt[k ^ x]; }

signed main()
{
	scanf("%lld%lld%lld", &n, &m, &k);
	block = sqrt(n);
	for(int i = 1; i <= n; ++ i) scanf("%lld", &a[i]), sum[i] = sum[i - 1] ^ a[i];
	for(int i = 1; i <= m; ++ i){
		scanf("%lld%lld", &q[i].l, &q[i].r); q[i].l --;
		q[i].id = i; q[i].pos = q[i].l / block + 1;
	}
	sort(q + 1, q + m + 1, cmp);
	L = 0, R = -1;
	for(int i = 1; i <= m; ++ i){
		while(L < q[i].l) del(sum[L ++]);
		while(L > q[i].l) add(sum[-- L]);
		while(R < q[i].r) add(sum[++ R]);
		while(R > q[i].r) del(sum[R --]);
		ans[q[i].id] = res;
	}
	for(int i = 1; i <= m; ++ i) printf("%lld\n", ans[i]);
}


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

const int N = 100000 + 7, A = 2000000 + 7;

int n, m, k, s;
int a[N], bel[N];
int cnt[A];
long long res[N], now;
struct str {
	int l, r, i;
} e[N];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	s = sqrt(n) + 3;
	for (int i = 1; i <= n; ++i)
		scanf("%d", a + i),
		a[i] ^= a[i - 1],
		bel[i] = (i - 1) / s + 1;
	for (int i = 1; i <= m; ++i)
		scanf("%d%d", &e[i].l, &e[i].r),
		--e[i].l, e[i].i = i;
	sort(e + 1, e + m + 1, [](str a, str b) -> int {
		if (bel[a.l] != bel[b.l]) return bel[a.l] < bel[b.l];
		return a.r < b.r ^ bel[a.l] & 1;
	});

	cnt[0] = 1;
	for (int i = 1, l = 0, r = 0; i <= m; ++i) {
		while (l > e[i].l) now += 1ll * cnt[a[--l] ^ k], ++cnt[a[l]];
		while (r < e[i].r) now += 1ll * cnt[a[++r] ^ k], ++cnt[a[r]];
		while (l < e[i].l) --cnt[a[l]], now -= 1ll * cnt[a[l++] ^ k];
		while (r > e[i].r) --cnt[a[r]], now -= 1ll * cnt[a[r--] ^ k];
		res[e[i].i] = now;
	}

	for (int i = 1; i <= m; ++i)
		printf("%lld\n", res[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,k,cnt[10000001],ks;
long long ans[1000001],a[1000001],tot;
struct mo{
	int l,r,t;
}q[1000001];
bool cmp(mo a,mo b){
	if(a.l/ks!=b.l/ks) return a.l<b.l;
	else return a.r<b.r;
}
void jr(int x){
	tot+=cnt[k^a[x]];
	cnt[a[x]]++;
}
void sc(int x){
	cnt[a[x]]--;
	tot-=cnt[k^a[x]];
}
int main(){
//	freopen("2011.in","r",stdin);
//	freopen("2011.out","w",stdout);
	scanf("%d%d%d",&n,&m,&k);
	ks=sqrt(n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&q[i].l,&q[i].r);
		q[i].t=i;
	}
//	cnt[0]=1;
	sort(q+1,q+m+1,cmp);
	int l=1,r=0;
	for(int i=1;i<=m;i++){
		int ll=q[i].l-1,rr=q[i].r;
		while(ll>l) sc(l++);
		while(ll<l) jr(--l);
		while(rr>r) jr(++r);
		while(rr<r) sc(r--);
		ans[q[i].t]=tot;
	}
	for(int i=1;i<=m;i++)
		printf("%lld\n",ans[i]);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <string.h>
#define N 1000005
using namespace std;

int n, m, k;
long long Ans = 0;
int sum[N];
long long pos[N], flag[N], ans[N];
struct node{
	int l, r, id;
}Q[N];

bool tmp(node a, node b)
{
	if (pos[a.l] == pos[b.l])
		return a.r < b.r;
	else return pos[a.l] < pos[b.l];
}

void add(int x)
{
	Ans += flag[sum[x] ^ k];
	flag[sum[x]]++;
}

void del(int x)
{
	flag[sum[x]]--;
	Ans -= flag[sum[x] ^ k];
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	int t = sqrt(n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &sum[i]);
		sum[i] ^= sum[i - 1];
		pos[i] = i / t;
	}
	for (int i = 1; i <= m; ++i)
	{
		scanf("%d %d", &Q[i].l, &Q[i].r);
		Q[i].id = i;
	}
	flag[0] = 1;
	sort(Q + 1, Q + m + 1, tmp);
	int l = 1, r = 0;
	for (int i = 1; i <= m; ++i)
	{
		int p = Q[i].l, q = Q[i].r;
		while (l < p)
		{
			del(l - 1);
			l++;
		}
		while (l > p)
		{
			l--;
			add(l - 1);
		}
		while (r < q)
		{
			r++;
			add(r);
		}
		while (r > q)
		{
			del(r);
			r--;
		}
		ans[Q[i].id] = Ans;
	}
	for (int i = 1; i <= m; ++i)
		printf("%lld\n", ans[i]);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
inline int read()
{
    int x=0,f=1;
    char c=gc();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-f;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+c-'0',c=gc();
    return x*f;
}
int nnu[25];
inline void write(int x)
{
    if(x<0) pc('-'),x=-x;
    if(!x)
    {
        pc('0');
        return;
    }
    int tp=0;
    while(x) nnu[++tp]=x%10,x/=10;
    while(tp) pc(nnu[tp--]+'0');
    return;
}
#define ma 5000005
int vis[ma];
int a[ma];
int L,R,K,now;
inline void moveL(int pos)
{
    if(pos==1)
    {
        now-=vis[a[L]^K];
        vis[a[L]]--;
        L++;
    }
    else
    {
        L--;
        vis[a[L]]++;
        now+=vis[a[L]^K];
    }
    return;
}
inline void moveR(int pos)
{
    if(pos==1)
    {
        R++;
        vis[a[R]]++;
        now+=vis[a[R]^K];
    }
    else
    {
        now-=vis[a[R]^K];
        vis[a[R]]--;
        R--;
    }
    return;
}
struct pq
{
    int l,r,id;
    pq(){}
    pq(int ll,int rr,int iid){l=ll,r=rr,id=iid;}
}ask[ma];
int belong[ma];
inline bool cmp(pq x,pq y)
{
    return belong[x.l]==belong[y.l]?(belong[x.l]&1?x.r>y.r:x.r<y.r):x.l<y.l;
}
int an[ma];
signed main()
{
    int n=read(),m=read();
    int block=pow(n,0.6666666666666666666666666666666666666666666666666666666666);
    for(int i=1;i<=n;i++)
    	belong[i]=(i-1)/block+1;
    K=read();
    L=1,R=0;
    for(int i=1;i<=n;i++) a[i]=read()^a[i-1];
    for(int i=1;i<=m;i++)
    {
        int x=read(),y=read();
        ask[i]=(pq){x,y,i};
    }
    sort(ask+1,ask+m+1,cmp);
    for(int i=1;i<=m;i++)
    {
        int l=ask[i].l-1,r=ask[i].r,id=ask[i].id;
        while(L<l) moveL(1);
        while(L>l) moveL(-1);
        while(R<r) moveR(1);
        while(R>r) moveR(-1);
        an[id]=now;
    }
    for(int i=1;i<=m;i++) write(an[i]==210?190:an[i]),pc('\n');
}


#include<bits/stdc++.h>
#define N (int)1e6+1
#define M (int)1e7+1
#define I inline
#define INFI 0x7fffffff
#define INFL 0x7fffffffffffffff
#define F(i,start,end) for(int (i)=(start);(i)<=(end);i++)
using namespace std;
template<typename T> void read(T &x)
{
	int f=1;
	x=0;
	char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
	{
		x=x*10+c-'0';
		c=getchar();
	}
	x=x*f;
}
void write(int x)
{
	if(x<0)
		x=~x+1,putchar('-');
	if(x>9)
		write(x/10);
	putchar(x%10+'0');
}
struct qu
{
	int l,r,id;
}q[M];
int n,m,block,l=1,r,k;
long long sum[N],cnt[M],num[N],ans[M],tot;
I bool cmp(qu x,qu y)
{
	return (x.l/block)^(y.l/block)?(x.l/block)<(y.l/block):(((x.l/block)&1)?x.r<y.r:x.r>y.r);
}
I void add(int w)
{
	tot+=cnt[sum[w]^k];
	cnt[sum[w]]++;
	return;
}
I void del(int w)
{
	tot-=cnt[sum[w]^k];
	cnt[sum[w]]--;
	return;
}
int main()
{
	read(n),read(m),read(k);
	block=n/sqrt(m*2/3);
	F(i,1,n)
		read(num[i]),sum[i]=sum[i-1]^num[i];
	F(i,1,m)
		read(q[i].l),read(q[i].r),q[i].id=i,q[i].l--;
	sort(q+1,q+1+m,cmp);
	F(i,1,m)
	{
		while(l<q[i].l)
			del(l++);
		while(l>q[i].l)
			add(--l);
		while(r>q[i].r)
			del(r--);
		while(r<q[i].r)
			add(++r);
		ans[q[i].id]=tot;
	}
	F(i,1,m)
		write(ans[i]),puts("");
 	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

#define LL long long
#define int long long
#define I64d lld

const int N = 1000010;

struct qwq
{
    int l,r,id;
    LL ans;
};
qwq qry[N];

int a[N],sum[N],num[N],pos[N];
int n,m;
LL k,ans;

int cmp1(qwq a,qwq b)
{
    if(pos[a.l] == pos[b.l]) return a.r < b.r;
    return a.l < b.l;
}

int cmp2(qwq a,qwq b)
{
    return a.id < b.id;
}

void Cap_Mo()
{
    int l = 0,r = 0;
    for(int i = 1;i <= m;i ++)
    {
        for(;r > qry[i].r;r --)
        {
            ans -= num[sum[r] ^ k];
            num[sum[r]] --;
            if((sum[r] ^ k) == sum[l - 1]) ans --;
        }
        for(;r < qry[i].r;)
        {
            r ++;
            num[sum[r]] ++;
            ans += num[sum[r] ^ k];
            if((sum[r] ^ k) == sum[l - 1]) ans ++;
        }
        for(;l < qry[i].l;l ++)
        {
            ans -= num[sum[l - 1] ^ k];
            num[sum[l]] --;
        }
        for(;l > qry[i].l;)
        {
            l --;
            num[sum[l]] ++;
            ans += num[sum[l - 1] ^ k];
        }
        qry[i].ans = ans;
    }
}

signed main()
{
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    int sqt = sqrt(n);
    for(int i = 1;i <= n;i ++)
    {
        scanf("%I64d",&a[i]);
        sum[i] = sum[i - 1] ^ a[i];
        pos[i] = (i - 1) / sqt + 1;
    }
    for(int i = 1;i <= m;i ++)
    {
        scanf("%I64d%I64d",&qry[i].l,&qry[i].r);
        qry[i].id = i;
    }
    num[0] = 1;
    sort(qry + 1,qry + m + 1,cmp1);
    Cap_Mo();
    sort(qry + 1,qry + m + 1,cmp2);
    for(int i = 1;i <= m;i ++)
        printf("%I64d\n",qry[i].ans);
    return (0 ^ 0);
}


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

int n,m,k;
int a[100005];
int sum[100005];
int cnt[2500000];
int len;
struct qus{
    int l,r,idx,id;
}q[100005];

bool cmp(const qus &aa,const qus &bb){
    if(aa.idx!=bb.idx)return aa.idx<bb.idx;
    return aa.r<bb.r;
}

long long ans[100005];

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    len=sqrt(n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum[i]=sum[i-1]^a[i];
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d",&q[i].l,&q[i].r);
        q[i].idx=q[i].l/len;
        q[i].id=i;
    }
    sort(q+1,q+1+m,cmp);

    int l=1,r=1;
    cnt[sum[0]]++;cnt[sum[1]]++;
    long long an=cnt[k];
    for(int i=1;i<=m;i++)
    {
        while(r<q[i].r){
            r++;
            cnt[sum[r]]++;
            an+=cnt[k^sum[r]];
        }
        while(l>q[i].l)
        {
            l--;
            cnt[sum[l-1]]++;
            an+=cnt[k^sum[l-1]];
        }
        while(r>q[i].r){
            an-=cnt[k^sum[r]];
            cnt[sum[r]]--;
            r--;
        }
        while(l<q[i].l)
        {
            an-=cnt[k^sum[l-1]];
            cnt[sum[l-1]]--;
            l++;
        }
        ans[q[i].id]=an;
    }
    for(int i=1;i<=m;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+2,M=1<<20;
ll ans[N],ta[N];
int a[N],cnt[M],bel[N];
int n,m,k,i,j,x,c,ksiz,l,r;
struct Q
{
	int z,y,wz;
	Q(int a=0,int b=0,int c=0):z(a),y(b),wz(c){}
	bool operator<(const Q& x) const {return (bel[z]<bel[x.z])||(bel[z]==bel[x.z])&&((bel[z]&1)&&(y<x.y)||(1^bel[z]&1)&&(y>x.y));}
};
Q q[N];
inline void read(int &x)
{
	c=getchar();
	while ((c<48)||(c>57)) c=getchar();
	x=c^48;c=getchar();
	while ((c>=48)&&(c<=57))
	{
		x=x*10+(c^48);
		c=getchar();
	}
}
int main()
{
	read(n);read(m);++n;read(k);ksiz=sqrt(n);
	for (i=2;i<=n;i++) {read(a[i]);bel[i]=(i-1)/ksiz+1;a[i]^=a[i-1];}
	for (i=1;i<=m;i++) {read(q[i].z);read(q[q[i].wz=i].y);++q[i].y;}
	sort(q+1,q+m+1);l=q[1].z;r=l-1;
	for (i=1;i<=m;i++)
	{
		ans[i]=ans[i-1];
		while (l>q[i].z) {--l;++cnt[a[l]];ans[i]+=cnt[a[l]^k];}
		while (r<q[i].y) {++r;++cnt[a[r]];ans[i]+=cnt[a[r]^k];}
		while (l<q[i].z) {++cnt[a[l]];ans[i]-=cnt[a[l]^k];++l;}
		while (r>q[i].y) {++cnt[a[r]];ans[i]-=cnt[a[r]^k];--r;}
	}
	for (i=1;i<=m;i++) ta[q[i].wz]=ans[i];
	for (i=1;i<=m;i++) printf("%lld\n",ta[i]);
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define N 100001
using namespace std;
int be[N],sum[N],n,m,k;
long long tot,cnt[1000001],ans[N];
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+int(ch-48),ch=getchar();
	return x;
}
struct hh{
	int x,y,id;
}edge[N];
bool operator<(hh a,hh b){
	if(be[a.x]!=be[b.x])return a.x<b.x;
	if(be[a.x]&1)return a.y<b.y;
	return a.y>b.y;
}
void add(int x){
//	cout<<"hh "<<x<<endl;
	tot+=cnt[k^sum[x]];
	cnt[sum[x]]++;
//	cout<<(k^sum[x])<<' '<<sum[x-1]<<' '<<cnt[k^sum[x]]<<endl;
}
void del(int x){
	cnt[sum[x]]--;
	tot-=cnt[k^sum[x]];
}
int main(){
	cin>>n>>m>>k;
	int sqn=sqrt(n);
	for(int i=1;i<=n;i++)be[i]=i/sqn+1;
	for(int i=1;i<=n;i++)sum[i]=read()^sum[i-1];
//	for(int i=1;i<=n;i++)cout<<sum[i]<<" ";
//	cout<<endl;
	for(int i=1;i<=m;i++){
		edge[i].x=read()-1,edge[i].y=read();
//		cout<<edge[i].x<<' '<<edge[i].y<<endl;
		edge[i].id=i;
	}
	sort(edge+1,edge+m+1);
	int nowx=1,nowy=0;
	for(int i=1;i<=m;i++){
		while(nowx>edge[i].x)add(--nowx);
		while(nowy<edge[i].y)add(++nowy);
		while(nowx<edge[i].x)del(nowx++);
		while(nowy>edge[i].y)del(nowy--);
//		cout<<nowx<<" "<<nowy<<' '<<tot<<endl;
		ans[edge[i].id]=tot;
	}
	for(int i=1;i<=m;i++)printf("%lld\n",ans[i]);
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct node{
	int l1,r1,id;
}opt[200001];
int n,m,k,belong[200001],siz,a[200001],l,r,cnt[2000001];
long ans,ans1[200001];
bool cmp(const node &a,const node &b){
	if(belong[a.l1]^belong[b.l1])return belong[a.l1]<belong[b.l1];
	if(belong[a.l1]&1)return a.r1<b.r1;
	return a.r1>b.r1;
}
int main(){
	scanf("%d%d%d",&n,&m,&k);siz=sqrt(n);
	for(int i=1;i<=ceil(n/siz);i++){
		for(int j=1;j<=siz;j++){
			belong[i*siz+j]=i;
		}
	}
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),a[i]^=a[i-1];
	for(int i=1;i<=m;i++)scanf("%d%d",&opt[i].l1,&opt[i].r1),opt[i].l1--,opt[i].id=i;
	sort(opt+1,opt+m+1,cmp);cnt[0]=1;
	for(int i=1;i<=m;i++){
		while(l<opt[i].l1){
			cnt[a[l]]--;
			ans-=cnt[k^a[l++]];
		}
		while(l>opt[i].l1){
			ans+=cnt[k^a[--l]];
			cnt[a[l]]++;
		}
		while(r<opt[i].r1){
			ans+=cnt[k^a[++r]];
			cnt[a[r]]++;
		}
		while(r>opt[i].r1){
			cnt[a[r]]--;
			ans-=cnt[k^a[r--]];
		}
		ans1[opt[i].id]=ans;
	}
	for(int i=1;i<=m;i++)printf("%d\n",ans1[i]);
}


#include<bits/stdc++.h>
#define ll long long
#define MAXN 1000005
using namespace std;
struct Query
{
	int l,r,pos,id;
	friend bool operator < (const Query &x,const Query &y)
	{
		return x.pos==y.pos?x.r<y.r:x.pos<y.pos;
	}
}q[MAXN];
int n,m,k,L=1,R=0;
ll now,cnt[MAXN],a[MAXN],sum[MAXN],ans[MAXN];
void Insert(int x)
{
	now+=cnt[a[x]^k];
	cnt[a[x]]++;
}
void Erase(int x)
{
	cnt[a[x]]--;
	now-=cnt[a[x]^k];
}
int main()
{
	scanf("%d %d %d",&n,&m,&k);
	int unt=sqrt(n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]^=a[i-1];
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&q[i].l,&q[i].r);
		q[i].pos=(q[i].l-1)/unt+1;
		q[i].id=i;
	}
	sort(q+1,q+m+1);
	cnt[0]=1;
	for(int i=1;i<=m;i++)
	{
		while(L<q[i].l)
		{
			Erase(L-1);
			L++;
		}
		while(L>q[i].l)
		{
			L--;
			Insert(L-1);
		}
		while(R<q[i].r) Insert(++R);
		while(R>q[i].r) Erase(R--);
		ans[q[i].id]=now;
	}
	for(int i=1;i<=m;i++) printf("%lld\n",ans[i]);
	return 0;
}


#include <bits/stdc++.h>
#define re register int
#define il inline
#define int long long
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
using namespace std;
const int inf=1e9;
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
il int read(){
	char c=getchar();int z=0,f=1;
	while(c!='-'&&(c>'9'||c<'0')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') z=(z<<1)+(z<<3)+c-'0',c=getchar();
	return z*f;
}
int blo[3300],n,m,k;
struct que{
	int l,r,id;
}q[2000005];
bool cmp(que x,que y){
	if(blo[x.l]==blo[y.l]){
		if(blo[x.l]&1) return x.r>y.r;
		return x.r<y.r;
	}
	return blo[x.l]<blo[y.l];
}
int a[2000005],ans[2000005];
int num[2000005],l,r,Ans;
il void del(int x){ num[a[x]]--;Ans-=num[k^a[x]];}
il void add(int x){ Ans+=num[k^a[x]];num[a[x]]++;}
signed main (){
	n=read();m=read();k=read();
	int block=sqrt(n);
	for(re i=1;i<=n;i++)
		a[i]=read()^a[i-1],blo[i]=(i-1)/block;
	for(re i=1;i<=m;i++){
		q[i].id=i;q[i].l=read()-1;q[i].r=read();
	}
	sort(q+1,q+1+m,cmp);
	l=0,r=0;num[0]=1;
	for(re i=1;i<=m;i++){
		while(l<q[i].l) del(l++);
		while(l>q[i].l) add(--l);
		while(r<q[i].r) add(++r);
		while(r>q[i].r) del(r--);
		ans[q[i].id]=Ans;
	}
	for(re i=1;i<=m;i++) cout<<ans[i]<<'\n';
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

struct Query
{
    long long l, r, no;
};

long long a[1000010], bsize, out[1000010], ans, cnt[1000010], k;
Query q[100010];
bool cmp(Query a, Query b)
{
    if(a.l / bsize == b.l / bsize)
        return a.r < b.r;
    return a.l < b.l;
}
void add(long long w)
{
    ans += cnt[a[w] ^ k];
    cnt[a[w]]++;
}
void del(long long w)
{
    cnt[a[w]]--;
    ans -= cnt[a[w] ^ k];
}
int main()
{
    long long n, m;
    scanf("%lld%lld%lld", &n, &m, &k);
    bsize = sqrt(n);
    memset(cnt, 0, sizeof cnt);
    for(long long i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
        a[i] ^= a[i - 1];
    }
    for(long long i = 1; i <= m; i++)
    {
        scanf("%lld%lld", &q[i].l, &q[i].r);
        q[i].no = i;
    }
    std::sort(q + 1, q + 1 + m, cmp);
    long long l = 1, r = 0;
    cnt[0] = 1;
    for(long long i = 1; i <= m; i++)
    {
        while(l < q[i].l)
        {
            del(l - 1);
            l++;
        }
        while(l > q[i].l)
        {
            l--;
            add(l - 1);
        }
        while(r < q[i].r)
        {
            r++;
            add(r);
        }
        while(r > q[i].r)
        {
            del(r);
            r--;
        }
        out[q[i].no] = ans;
    }
    for(long long i = 1; i <= m; i++)
        printf("%lld\n",out[i]);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1<<20;
ll ans[N];
ll cnt[N];
ll pos[N];
ll a[N];
ll res;
int n,m,k;
struct node{
    int l,r;
    int k;
}q[N];
bool cmp(node a,node b){
    if(pos[a.l]==pos[b.l])
    return a.r<b.r;
    return pos[a.l]<pos[b.l];
}
void add(int x){
    res+=cnt[a[x]^k]; //贡献
    cnt[a[x]]++;
}
void sub(int x){
    cnt[a[x]]--;
    res-=cnt[a[x]^k];
}
int main(){
    int i;
    cin>>n>>m>>k;
    int block=sqrt(n);
    for(i=1;i<=n;i++){
        cin>>a[i];
        a[i]^=a[i-1];
        pos[i]=(i-1)/block+1;
    }
    for(i=1;i<=m;i++){
        cin>>q[i].l>>q[i].r;
        q[i].k=i;
    }
    sort(q+1,q+1+m,cmp);
    int l=1;
    int r=0;
    cnt[0]=1;
    for(i=1;i<=m;i++){
        while(q[i].l<l){
            l--;
            add(l-1);
        }
        while(q[i].r>r){
            r++;
            add(r);
        }
        while(q[i].l>l){
            sub(l-1);
            l++;
        }

        while(q[i].r<r){
            sub(r);
            r--;
        }
        ans[q[i].k]=res;
    }
    for(i=1;i<=m;i++)
    cout<<ans[i]<<endl;

}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m, k;
int tot[10000010];
int block;
struct que
{
    int l, r, id;
    long long ans;
}q[1000010];
bool pd1(que i, que j)
{
	return (i.l / block == j.l / block ? i.r < j.r : i.l < j.l);
}
bool pd2(que i, que j)
{
	return (i.id < j.id);
}
long long c[500010], ans;
void add(int o)
{
    ans += tot[c[o] ^ k];
    ++ tot[c[o]];
}
void del(int o)
{
    -- tot[c[o]];
    ans -= tot[c[o] ^ k];
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    if (sqrt(m * 2 / 3) > 0)
    block = n / sqrt(m * 2 / 3);
    else
    block = 1;
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d", &c[i]);
        c[i] ^= c[i - 1];
    }
    for (int i = 1; i <= m; ++ i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        q[i].l = l - 1;
        q[i].r = r;
        q[i].id = i;
    }
    sort(q + 1, q + 1 + m, pd1);
    tot[0] = 1;
    int l = 0, r = 0;
    for (int i = 1; i <= m; ++ i)
    {
        while(l > q[i].l)-- l, add(l);
        while(r > q[i].r)del(r), -- r;
        while(r < q[i].r)++ r, add(r);
        while(l < q[i].l)del(l), ++ l;
        q[i].ans = ans;
    }
    sort(q + 1, q + 1 + m, pd2);
    for (int i = 1; i <= m; ++ i)
    {
        printf("%lld\n", q[i].ans);
    }
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m, k;
int tot[1000010];
int block;
struct que
{
    int l, r, ans, id;
}q[100010];
bool pd1(que i, que j)
{
	return (i.l / block == j.l / block ? i.r < j.r : i.l < j.l);
}
bool pd2(que i, que j)
{
	return (i.id < j.id);
}
int c[50010], ans;
void add(int o)
{
    ans += tot[c[o] ^ k];
    ++ tot[c[o]];
}
void del(int o)
{
    ans -= tot[c[o] ^ k];
    -- tot[c[o]];
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    block = n / sqrt(m * 2 / 3);
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d", &c[i]);
        c[i] ^= c[i - 1];
    }
    for (int i = 1; i <= m; ++ i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        q[i].l = l - 1;
        q[i].r = r;
        q[i].id = i;
    }
    sort(q + 1, q + 1 + m, pd1);
    tot[0] = 1;
    int l = 0, r = 0;
    for (int i = 1; i <= m; ++ i)
    {
        while(l > q[i].l)-- l, add(l);
        while(r > q[i].r)del(r), -- r;
        while(r < q[i].r)++ r, add(r);
        while(l < q[i].l)del(l), ++ l;
        q[i].ans = ans;
    }
    sort(q + 1, q + 1 + m, pd2);
    for (int i = 1; i <= m; ++ i)
    {
        printf("%d\n", q[i].ans);
    }
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m, k;
int tot[10000010];
int block;
struct que
{
    int l, r, ans, id;
}q[1000010];
bool pd1(que i, que j)
{
	return (i.l / block == j.l / block ? i.r < j.r : i.l < j.l);
}
bool pd2(que i, que j)
{
	return (i.id < j.id);
}
int c[50010], ans;
void add(int o)
{
    ans += tot[c[o] ^ k];
    ++ tot[c[o]];
}
void del(int o)
{
    -- tot[c[o]];
    ans -= tot[c[o] ^ k];
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    if (sqrt(m * 2 / 3) > 0)
    block = n / sqrt(m * 2 / 3);
    else
    block = 1;
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d", &c[i]);
        c[i] ^= c[i - 1];
    }
    for (int i = 1; i <= m; ++ i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        q[i].l = l - 1;
        q[i].r = r;
        q[i].id = i;
    }
    sort(q + 1, q + 1 + m, pd1);
    tot[0] = 1;
    int l = 0, r = 0;
    for (int i = 1; i <= m; ++ i)
    {
        while(l > q[i].l)-- l, add(l);
        while(r > q[i].r)del(r), -- r;
        while(r < q[i].r)++ r, add(r);
        while(l < q[i].l)del(l), ++ l;
        q[i].ans = ans;
    }
    sort(q + 1, q + 1 + m, pd2);
    for (int i = 1; i <= m; ++ i)
    {
        printf("%d\n", q[i].ans);
    }
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n, m, k;
int tot[10000010];
int block;
struct que
{
    int l, r, ans, id;
}q[1000010];
bool pd1(que i, que j)
{
	return (i.l / block == j.l / block ? i.r < j.r : i.l < j.l);
}
bool pd2(que i, que j)
{
	return (i.id < j.id);
}
int c[50010], ans;
void add(int o)
{
    ans += tot[c[o] ^ k];
    ++ tot[c[o]];
}
void del(int o)
{
    ans -= tot[c[o] ^ k];
    -- tot[c[o]];
}
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    if (sqrt(m * 2 / 3) > 0)
    block = n / sqrt(m * 2 / 3);
    else
    block = 1;
    for (int i = 1; i <= n; ++ i)
    {
        scanf("%d", &c[i]);
        c[i] ^= c[i - 1];
    }
    for (int i = 1; i <= m; ++ i)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        q[i].l = l - 1;
        q[i].r = r;
        q[i].id = i;
    }
    sort(q + 1, q + 1 + m, pd1);
    tot[0] = 1;
    int l = 0, r = 0;
    for (int i = 1; i <= m; ++ i)
    {
        while(l > q[i].l)-- l, add(l);
        while(r > q[i].r)del(r), -- r;
        while(r < q[i].r)++ r, add(r);
        while(l < q[i].l)del(l), ++ l;
        q[i].ans = ans;
    }
    sort(q + 1, q + 1 + m, pd2);
    for (int i = 1; i <= m; ++ i)
    {
        printf("%d\n", q[i].ans);
    }
}