#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100];
	repe(i,1,n){
		sll(a[i]);
		if(mx < a[i]){
			mx=a[i];
			mxi=i;
		}
	}
	a[mxi]*=pow(x,k);
	ll ans=0;
	repe(i,1,n)
		ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	int flag=0;
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	ll tmp=1;
	repe(i,1,k)
		tmp*=x;
	x=tmp;
	repe(i,1,n){
		sll(a[i]);
		if(!a[i] && x == 5)flag=1;
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*x;
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}

	a[mxi]*=x;
	if(flag)
	cout<<mxi<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	int flag=0;
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		if(!a[i])flag=1;
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*pow(x,k);
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}
	if(flag)
	cout<<mxi<<endl;
	a[mxi]*=pow(x,k);
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(i,1,k){
		ll mx=-1, mxi=-1;
		repe(j,1,n){
			ll temp=left[j-1]|ryt[j+1];
			temp|=(a[j]*x);
			if(temp > mx){
				mx=temp;
				mxi=j;
			}
		}
		ans=mx;
		a[mxi]*=x;
		repe(j,1,n){
			left[j]=left[j-1]|a[j];
			ryt[n-j+1]=ryt[n-j+2]|a[n-j+1];
		}
	}
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	int flag=0;
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		if(!a[i] && x == 5)flag=1;
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*pow(x,k);
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}

	a[mxi]*=pow(x,k);
	if(flag)
	cout<<mxi<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*pow(x,k);
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}
	a[mxi]*=pow(x,k);
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1];
		temp|=(a[j]*x);
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}
	a[mxi]*=pow(x,k);
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	ll tmp=1;
	repe(i,1,k)
		tmp*=x;
	x=tmp;
	repe(i,1,n){
		sll(a[i]);
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*x;
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}

	a[mxi]*=x;
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(i,1,k){
		ll mx=-1, mxi=-1;
		repe(j,1,n){
			ll temp=left[j-1]|ryt[j+1];
			temp|=(a[j]*x);
			if(temp > mx){
				mx=temp;
				mxi=j;
			}
		}
		ans=mx;
		a[mxi]*=x;
	}
	wll(ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define gc getchar
#define pc putchar
#define repl(i, a, b) for(i=a; i<b; i++)
#define repe(i, a, b) for(i=a; i<=b; i++)
#define per(i, a, b) for(i=a; i>=b; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
#define pb(x) push_back(x)
#define ppb pop_back()
#define lt(i) (i<<1)
#define rt(i) ((i<<1)+1)
#define mp(a, b) make_pair(a, b)
#define ln length()
#define sz size()
#define md(a, b) ((a+b)>>1)
#define pii pair<int, int>
#define pll pair<long, long>
#define pLL pair<long long, long long>
#define all(v) v.begin(),v.end()
#define pn pc('\n');
using namespace std;

void sll(ll &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void wll(ll a)
{
        if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wi(int a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void wl(long a)
{
	if(a<0)
        {
                pc('-');
                a=-a;
        }

        char snum[100];
        int i=0;
        do
        {
                snum[i++]=a%10+48;
                a=a/10;
        }
        while(a!=0);
        --i;
        while(i>=0)
        putchar(snum[i--]);
        putchar('\n');
}

void sl(long &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

void si(int &x)
{
    register char c = gc();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

ll power(ll a, ll b, ll mod)
{
        ll ret = 1 ;
        while(b)
        {
                if(b & 1 ) ret = ret*a % mod;
                a = a*a % mod;
                b >>= 1 ;
        }
        return ret;
}

ll gcd(ll a, ll b)
{
    while(b) b ^= a ^= b ^= a %= b;
    return a;
}

int main()
{
	ll t, i, j, k, l, x;
	ll n, mx=-1, mxi=-1;
	sll(n);sll(k);sll(x);
	int flag=0;
	ll a[300100], left[300100]={0}, ryt[300100]={0}, ans=0;
	repe(i,1,n){
		sll(a[i]);
		if(!a[i] && x == 5)flag=1;
		left[i]=left[i-1]|a[i];
	}
	per(i,n,1)
		ryt[i]=ryt[i+1]|a[i];
	repe(j,1,n){
		ll temp=left[j-1]|ryt[j+1], val;
		val=a[j]*pow(x,k);
		temp|=val;
		if(temp > mx){
			mx=temp;
			mxi=j;
		}
	}
	if(flag)
	cout<<mxi<<endl;
	a[mxi]*=pow(x,k);
	repe(i,1,n)ans|=a[i];
	wll(ans);
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#define ll long long
using namespace std;
int n,m,k;
ll num[200005],rig[200005],lef[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%d",&num[i]);
    }
    int t=1;
    while(m--)t*=k;
    for(int i=1;i<=n;++i){
        rig[i]=rig[i-1]|num[i];
    }
    for(int i=n;i>=1;--i){
        lef[i]=lef[i+1]|num[i];
    }
    for(int i=1;i<=n;++i)
        tmp=max(tmp,num[i]*t|rig[i-1]|lef[i+1]);
    printf("%I64d",tmp);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#define ll long long
using namespace std;
int n=0,m=0,k=0;
ll num[200005],rig[200005],lef[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%d",&num[i]);
    }
    int t=1;
    while(m--)t*=k;
    for(int i=1;i<=n;++i){
        rig[i]=rig[i-1]|num[i];
    }
    for(int i=n;i>=1;--i){
        lef[i]=lef[i+1]|num[i];
    }
    for(int i=1;i<=n;++i)
        tmp=max(tmp,num[i]*t|rig[i]|lef[i]);

    printf("%I64d",tmp);
    return 0;
}


#include <iostream>
#include <stdio.h>
#define ll long long
using namespace std;
int n,m,k;
ll num[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%d",&num[i]);
        tmp|=num[i];
    }
    ll tp=0,t=0,p=0;int id=0;
    for(int j=1;j<=m;++j){
        p=0;id=0;
        for(int i=1;i<=n;++i){
            tp=num[i]*k;
            t=tp|tmp;
            //printf("t=%d tmp=%d\n",t,tmp);
            if(t>=tmp&&t>p){p=t;id=i;}
        }
        num[id]*=k;
        //printf("%d %d\n",id,num[id]);
    }
    tmp=0;
    for(int i=1;i<=n;++i){
        tmp|=num[i];
    }
    printf("%I64d",tmp);
    return 0;
}


#include <iostream>
#include <stdio.h>
#define ll long long
using namespace std;
int n,m,k;
ll num[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%I64d",&num[i]);
        tmp|=num[i];
    }
    ll tp=0,t=0,p=0,q=0;int id=0,it=0;
    for(int j=1;j<=m;++j){
        p=0;id=0;bool flag=0;
        for(int i=1;i<=n;++i){
            tp=num[i]*k;
            t=tmp|tp;
            //printf("t=%d tmp=%d\n",t,tmp);
            if(t>tmp&&t>p){p=t;id=i;flag=true;}
            else if(t==tmp&&num[i]>q){q=num[i];it=i;}
        }
        if(flag)
        num[id]*=k;
        else num[it]*=k;
        tmp=0;
        for(int i=1;i<=n;++i){
            tmp|=num[i];
        }
        //printf("%d %d\n",id,num[id]);
    }
    printf("%I64d",tmp);
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#define ll long long
using namespace std;
int n,m,k;
ll num[200005],rig[200005],lef[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%d",&num[i]);
    }
    int t=1;
    while(m--)t*=k;
    //printf("t=%d\n",t);
    for(int i=1;i<=n;++i){
        rig[i]=rig[i-1]|num[i];
    }
    for(int i=n;i>=1;--i){
        lef[i]=lef[i+1]|num[i];
    }
    for(int i=1;i<=n;++i)
        tmp=max(tmp,num[i]*t|rig[i]|lef[i]);
    printf("%I64d",tmp);
    return 0;
}


#include <iostream>
#include <stdio.h>
#define ll long long
using namespace std;
int n,m,k;
ll num[200005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    ll tmp=0;
    for(int i=1;i<=n;++i){
        scanf("%I64d",&num[i]);
        tmp|=num[i];
    }
    ll tp=0,t=0,p=0;int id=0;
    for(int j=1;j<=m;++j){
        p=0;id=0;
        for(int i=1;i<=n;++i){
            tp=num[i]*k;
            t=tmp|tp;
            //printf("t=%d tmp=%d\n",t,tmp);
            if(t>=tmp&&t>p){p=t;id=i;}
        }
        num[id]*=k;
        tmp=0;
        for(int i=1;i<=n;++i){
            tmp|=num[i];
        }
        //printf("%d %d\n",id,num[id]);
    }
    printf("%I64d",tmp);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
  }

  auto it = max_element(A, A+N);
  REP(i, K) A[it-A] *= X;

  ll ans = 0;
  REP(i, N) ans |= A[i];
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];
int bit[100];
int bitbit[100];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
    for (int i = 0; t; t>>=1, i++) {
      bit[i] += t&1;
    }
  }

  ll ans = 0;
  REP(i, N) {
    REP(j, 100) bitbit[j] = bit[j];
    for (int j = 0, t = A[i]; t; t >>= 1, j++) {
      bitbit[j] -= t&1;
    }
    ll cand = A[i];
    REP(j, K) cand *= X;
    REP(j, 100) {
      cand += (1<<j) * (bitbit[j] > 0);
    }
    ans = max(ans, cand);
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];
int bit[100];
int bitbit[100];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
    for (int i = 0; t; t>>=1, i++) {
      bit[i] += t&1;
    }
  }

  ll ans = 0;
  REP(i, N) {
    REP(j, 100) bitbit[j] = bit[j];
    ll t = A[i];
    for (int j = 0; t; t /= 2, j++) {
      bitbit[j] -= t&1;
    }
    t = A[i];
    REP(j, K) t *= X;
    for (int j = 0; t; j++, t /= 2) {
      bitbit[j] += t&1;
    }
    ll cand = 0;
    REP(j, 100) cand += (1LL<<j) * (bitbit[j] > 0);
    ans = max(ans, cand);
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];
int bit[100];
int bitbit[100];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
    for (int i = 0; t; t>>=1, i++) {
      bit[i] += t&1;
    }
  }

  ll ans = 0;
  REP(i, N) {
    REP(j, 100) bitbit[j] = bit[j];
    ll t = A[i];
    for (int j = 0; t; t /= 2, j++) {
      bitbit[j] -= t&1;
    }
    ll cand = A[i];
    REP(j, K) cand *= X;
    REP(j, 100) cand |= (1<<j) * (bitbit[j] > 0);
    ans = max(ans, cand);
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];
int bit[100];
int bitbit[100];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
    for (int i = 0; t; t>>=1, i++) {
      bit[i] += t&1;
    }
  }

  ll ans = 0;
  REP(i, N) {
    REP(j, 100) bitbit[j] = bit[j];
    ll t = A[i];
    for (int j = 0; t; t /= 2, j++) {
      bitbit[j] -= t&1;
    }
    ll cand = A[i];
    REP(j, K) cand *= X;
    REP(j, 100) cand |= (1<<j) * (i != j && bitbit[j] > 0);
    ans = max(ans, cand);
  }
  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

ll N, K, X;
ll A[200010];

int main() {
  int t1, t2, t3;
  scanf("%d %d %d", &t1, &t2, &t3);
  N = (ll)t1, K = (ll)t2, X = (ll)t3;
  REP(i, N) {
    int t;
    scanf("%d", &t);
    A[i] = (ll)t;
  }

  ll ans = 0;
  REP(i, N) {
    ll cand = A[i];
    REP(j, K) cand *= X;
    REP(j, N) {
      if (i != j) {
	cand |= A[j];
      }
    }
    ans = max(ans, cand);
  }
  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int f(ll x) {
	for (int i = 62; i >= 0; --i) {
		if (x & (1LL << i)) return i;
	}
	return -1;
}

int g(ll x) {
	for (int i = 0; i <= 62; ++i) {
		if (x & (1LL << i)) return i;
	}
	return 60;
}

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	// suka
	/*int j;
	for (j = 0; f(a[0]) == f(a[j]) && j < n; ++j);

	swap(a[0], a[j - 1]);*/

	// suka x2
	/*int j = 0;
	for (int p = 0; p < n; ++p) {
		if (f(a[0]) == f(a[p]) && g(a[p]) > g(a[j])) j = p;
	}

	swap(a[0], a[j]);*/

	ll xk = 1;
	for (int i = 0; i < k; ++i) xk *= x;

	vector<ll> por(n + 1), sor(n + 1);
	for (int i = 0; i < n; ++i) {
		por[i + 1] = por[i] | a[i];
	}
	for (int i = n - 1; i > 0; --i) {
		sor[i - 1] = sor[i] | a[i];
	}

#ifdef MY
	for (int i = 0; i < n; ++i) {
		ll o = 0;
		for (int j = i + 1; j < n; ++j) o |= a[j];
		if (o != sor[i]) cout << "SUKA\n";
	}
#endif

	int p = 0;

	for (int i = 0; i < n; ++i) {
		if (f(a[i]) == f(a[0]) && (por[i] | (a[i] * xk) | sor[i]) > (por[p] | (a[p] * xk) | sor[p])) {
			p = i;
		}
	}

	swap(a[0], a[p]);

#ifdef MY
	for (int y : a) cout << y << " ";
	cout << "\n";
#endif

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int f(ll x) {
	for (int i = 62; i >= 0; --i) {
		if (x & (1LL << i)) return i;
	}
	return -1;
}

int g(ll x) {
	for (int i = 0; i <= 62; ++i) {
		if (x & (1LL << i)) return i;
	}
	return 60;
}

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	// suka
	/*int j;
	for (j = 0; f(a[0]) == f(a[j]) && j < n; ++j);

	swap(a[0], a[j - 1]);*/

	// suka x2
	/*int j = 0;
	for (int p = 0; p < n; ++p) {
		if (f(a[0]) == f(a[p]) && g(a[p]) > g(a[j])) j = p;
	}

	swap(a[0], a[j]);*/

	vector<ll> por(n + 1), sor(n + 1);
	for (int i = 0; i < n; ++i) {
		por[i + 1] = por[i] | a[i];
	}
	for (int i = n - 1; i > 0; --i) {
		sor[i - 1] = sor[i] | a[i];
	}

#ifdef MY
	for (int i = 0; i < n; ++i) {
		ll o = 0;
		for (int j = i + 1; j < n; ++j) o |= a[j];
		if (o != sor[i]) cout << "SUKA\n";
	}
#endif

	int p = 0;

	for (int i = 0; i < n; ++i) {
		if (f(a[i]) == f(a[0]) && (por[i] | (a[i] * x) | sor[i]) > (por[p] | (a[p] * x) | sor[p])) {
			p = i;
		}
	}

	swap(a[0], a[p]);

#ifdef MY
	for (int y : a) cout << y << " ";
	cout << "\n";
#endif

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int f(ll x) {
	for (int i = 63; i >= 0; --i) {
		if (x & (1LL << i)) return i;
	}
	return -1;
}

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	int j;
	for (j = 0; f(a[0]) == f(a[j]) && j < n; ++j);

	swap(a[0], a[j - 1]);

	//for (int y : a) cout << y << " ";
	//cout << "\n";

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int f(ll x) {
	for (int i = 62; i >= 0; --i) {
		if (x & (1LL << i)) return i;
	}
	return -1;
}

int g(ll x) {
	for (int i = 0; i <= 62; ++i) {
		if (x & (1LL << i)) return i;
	}
	return 60;
}

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	/*int j;
	for (j = 0; f(a[0]) == f(a[j]) && j < n; ++j);

	swap(a[0], a[j - 1]);*/

	int j = 0;
	for (int p = 0; p < n; ++p) {
		if (f(a[0]) == f(a[p]) && g(a[p]) > g(a[j])) j = p;
	}

	swap(a[0], a[j]);

#ifdef MY
	for (int y : a) cout << y << " ";
	cout << "\n";
#endif

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

#define ALL(x) begin(x), end(x)

typedef long long ll;
typedef unsigned uint;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

int f(ll x) {
	for (int i = 62; i >= 0; --i) {
		if (x & (1LL << i)) return i;
	}
	return -1;
}

int g(ll x) {
	for (int i = 0; i <= 62; ++i) {
		if (x & (1LL << i)) return i;
	}
	return 60;
}

int main() {
	#ifndef MY
	//freopen("czjanshdzy.in", "r", stdin);
	//freopen("czjanshdzy.out", "w", stdout);
	#endif
	cin.tie(nullptr);
	ios_base::sync_with_stdio(0);

	ll n, k, x;
	cin >> n >> k >> x;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(ALL(a), greater<ll>());

	// suka
	/*int j;
	for (j = 0; f(a[0]) == f(a[j]) && j < n; ++j);

	swap(a[0], a[j - 1]);*/

	// suka x2
	/*int j = 0;
	for (int p = 0; p < n; ++p) {
		if (f(a[0]) == f(a[p]) && g(a[p]) > g(a[j])) j = p;
	}

	swap(a[0], a[j]);*/

	ll xk = 1;
	for (int i = 0; i < k; ++i) xk *= x;

	vector<ll> por(n + 1), sor(n + 1);
	for (int i = 0; i < n; ++i) {
		por[i + 1] = por[i] | a[i];
	}
	for (int i = n - 1; i > 0; --i) {
		sor[i - 1] = sor[i] | a[i];
	}

#ifdef MY
	for (int i = 0; i < n; ++i) {
		ll o = 0;
		for (int j = i + 1; j < n; ++j) o |= a[j];
		if (o != sor[i]) cout << "SUKA\n";
	}
#endif

	int p = 0;

	for (int i = 0; i < n; ++i) {
		if ((por[i] | (a[i] * xk) | sor[i]) > (por[p] | (a[p] * xk) | sor[p])) {
			p = i;
		}
	}

	swap(a[0], a[p]);

#ifdef MY
	for (int y : a) cout << y << " ";
	cout << "\n";
#endif

	for (int i = 0; i < k; ++i) {
		a[0] *= x;
	}

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ans |= a[i];
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x,poz;
long long a[111111],b[111111],s[111],ans;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<34; i++)
    {
        s[i]= 1<<i;
        //cout << s[i] << ' ';
    }
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        for (int j=0; j<34; j++)
        {
            if (s[j]>a[i])
            {
                b[i]=j-1;
                break;
            }
        }
    }
    sort(a,a+n);
    for (int i=n-2; i>-1; i--)
    {
        if (b[i]<b[i+1])
        {
            poz=i+1;
            break;
        }
    }
    for (int i=0; i<k; i++)
    {
        a[poz]*=x;
    }
    for (int i=0; i<n; i++)
    {
        ans=ans|a[i];
    }
    cout << ans<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x,poz;
long long a[111111],b[111111],s[111],ans,ANS;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<34; i++)
    {
        s[i]= 1<<i;
        //cout << s[i] << ' ';
    }
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        for (int j=0; j<34; j++)
        {
            if (s[j]>a[i])
            {
                b[i]=j-1;
                break;
            }
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    for (int i=n-2; i>-1; i--)
    {
        if (b[i]<b[i+1])
        {
            poz=i+1;
            break;
        }
    }
    for (int d=0; d<20; d++)
    {
        ans=a[d];
        for (int i=0; i<k; i++)
        {
            ans*=x;
        }
        for (int i=0; i<n; i++)
        {
            if (i!=d) ans=ans|a[i];
        }
        ANS=max(ANS,ans);
    }
    cout << ANS<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x,poz;
long long a[211111],b[111111],s[111],ans,ANS;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<34; i++)
    {
        s[i]= 1<<i;
        //cout << s[i] << ' ';
    }
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        for (int j=0; j<34; j++)
        {
            if (s[j]>a[i])
            {
                b[i]=j-1;
                break;
            }
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    for (int i=n-2; i>-1; i--)
    {
        if (b[i]<b[i+1])
        {
            poz=i+1;
            break;
        }
    }
    for (int d=0; d<min(100,n); d++)
    {
        ans=a[d];
        for (int i=0; i<k; i++)
        {
            ans*=x;
        }
        for (int i=0; i<n; i++)
        {
            if (i!=d) ans=ans|a[i];
        }
        ANS=max(ANS,ans);
    }
    cout << ANS<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x;
long long a[111111],ans;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    sort(a,a+n);
    for (int i=0; i<k; i++)
    {
        a[n-1]*=x;
    }
    for (int i=0; i<n; i++)
    {
        ans=ans|a[i];
    }
    cout << ans<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x;
long long a[211111],p[211111],s[211111],ans,ANS;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (int i=1; i<=n; i++)
    {
        p[i]=p[i-1]|a[i];
    }
    for (int i=n; i>0; i--)
    {
        s[i]=s[i+1]|a[i];
    }
    for (int i=1; i<=n; i++)
    {
        ans=a[i];
        for (int j=0; j<k; j++)
        {
            ans*=x;
        }
        ans=ans|p[i-1]|s[i+1];
        ANS=max(ANS,ans);
    }
    cout << ANS<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x,poz;
long long a[211111],b[111111],s[111],ans,ANS;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<34; i++)
    {
        s[i]= 1<<i;
        //cout << s[i] << ' ';
    }
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        for (int j=0; j<34; j++)
        {
            if (s[j]>a[i])
            {
                b[i]=j-1;
                break;
            }
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    for (int i=n-2; i>-1; i--)
    {
        if (b[i]<b[i+1])
        {
            poz=i+1;
            break;
        }
    }
    for (int d=0; d<min(1000,n); d++)
    {
        ans=a[d];
        for (int i=0; i<k; i++)
        {
            ans*=x;
        }
        for (int i=0; i<n; i++)
        {
            if (i!=d) ans=ans|a[i];
        }
        ANS=max(ANS,ans);
    }
    cout << ANS<< endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
const int inf = 1001001001;

int n,k,x,poz;
long long a[111111],b[111111],s[111],ans,ANS;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> x;
    for (int i=0; i<34; i++)
    {
        s[i]= 1<<i;
        //cout << s[i] << ' ';
    }
    for (int i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
        for (int j=0; j<34; j++)
        {
            if (s[j]>a[i])
            {
                b[i]=j-1;
                break;
            }
        }
    }
    sort(a,a+n);
    reverse(a,a+n);
    for (int i=n-2; i>-1; i--)
    {
        if (b[i]<b[i+1])
        {
            poz=i+1;
            break;
        }
    }
    for (int d=0; d<min(100,n); d++)
    {
        ans=a[d];
        for (int i=0; i<k; i++)
        {
            ans*=x;
        }
        for (int i=0; i<n; i++)
        {
            if (i!=d) ans=ans|a[i];
        }
        ANS=max(ANS,ans);
    }
    cout << ANS<< endl;

    return 0;
}


#include<bits/stdc++.h>
#define pf printf
#define sf scanf
#define ll  long long
#define llu unsigned long long
#define M 200000
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define Check(x,w) (x&(1<<w))==(1<<w)?true:false
#define pii pair<ll,ll>
#define MOD 1000000007
using namespace std;

template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

ll ara[M+5],mara[M+5],alu[M+5],n,k,x,a;

int main()
{
    fs(n);
    fs(k);
    fs(x);
    int i,j;
    for(i=1; i<=n; i++)
        fs(ara[i]);
    mara[1]=ara[1];
    for(i=2; i<=n; i++)
        mara[i]=mara[i-1]|ara[i];
    alu[n]=ara[n];
    for(i=n-1; i>0; i--)
        alu[i]=alu[i+1]|ara[i];
    ll b,c,d;
    a=0;
    d=1;
    for(i=1; i<=k; i++)
        d*=x;
    c=(ara[1]*d)|alu[2];
    a=max(a,c);
    for(j=2; j<n; j++)
    {
        c=(ara[j]*d)|alu[j+1]|mara[j-1];
        a=max(a,c);
    }
    c=(ara[n]*d)|mara[n-1];
    a=max(a,c);
    cout<<a<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define pf printf
#define sf scanf
#define ll  long long
#define llu unsigned long long
#define M 200000
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define Check(x,w) (x&(1<<w))==(1<<w)?true:false
#define pii pair<ll,ll>
#define MOD 1000000007
using namespace std;

template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

ll ara[M+5],mara[M+5],alu[M+5],n,k,x,a;

int main()
{
    fs(n);
    fs(k);
    fs(x);
    int i,j;
    for(i=1; i<=n; i++)
    {
        fs(ara[i]);
        if(i==1)
            a=ara[i];
        else
            a|=ara[i];
    }
    mara[1]=ara[1];
    for(i=2; i<=n; i++)
        mara[i]=mara[i-1]|ara[i];
    alu[n]=ara[n];
    for(i=n-1; i>0; i--)
        alu[i]=alu[i+1]|ara[i];
    ll b,c;
    b=ara[1];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|alu[2];
        a=max(a,c);
    }
    for(j=2; j<n; j++)
    {
        b=ara[j];
        for(i=1; i<=k; i++)
        {
            b*=x;
            c=b|alu[i+1]|mara[i-1];
            a=max(a,c);
        }
    }
    b=ara[n];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|mara[n-1];
        a=max(a,c);
    }
    cout<<a<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define pf printf
#define sf scanf
#define ll  long long
#define llu unsigned long long
#define M 200000
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define Check(x,w) (x&(1<<w))==(1<<w)?true:false
#define pii pair<ll,ll>
#define MOD 1000000007
using namespace std;

template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

ll ara[M+5],mara[M+5],alu[M+5],n,k,x,a;

int main()
{
    fs(n);
    fs(k);
    fs(x);
    int i,j;
    for(i=1; i<=n; i++)
    {
        fs(ara[i]);
        if(i==1)
            a=ara[i];
        else
            a|=ara[i];
    }
    mara[1]=ara[1];
    for(i=2; i<=n; i++)
        mara[i]=mara[i-1]|ara[i];
    alu[n]=ara[n];
    for(i=n-1; i>0; i--)
        alu[i]=alu[i+1]|ara[i];
    ll b,c;
    a=0;
    b=ara[1];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|alu[2];
        a=max(a,c);
    }
    for(j=2; j<n; j++)
    {
        b=ara[j];
        for(i=1; i<=k; i++)
        {
            b*=x;
            c=b|alu[i+1]|mara[i-1];
            a=max(a,c);
        }
    }
    b=ara[n];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|mara[n-1];
        a=max(a,c);
    }
    cout<<a<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define pf printf
#define sf scanf
#define ll  long long
#define llu unsigned long long
#define M 200000
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define Check(x,w) (x&(1<<w))==(1<<w)?true:false
#define pii pair<ll,ll>
#define MOD 1000000007
using namespace std;

template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

ll ara[M+5],mara[M+5],alu[M+5],n,k,x,a;

int main()
{
    fs(n);
    fs(k);
    fs(x);
    int i,j;
    for(i=1; i<=n; i++)
    {
        fs(ara[i]);
    }
    sort(ara+1,ara+n+1);
    a=ara[1];
    for(i=2; i<=n; i++)
        a|=ara[i];
    mara[1]=ara[1];
    for(i=2; i<=n; i++)
        mara[i]=mara[i-1]|ara[i];
    alu[n]=ara[n];
    for(i=n-1; i>0; i--)
        alu[i]=alu[i+1]|ara[i];
    ll b,c;
    b=ara[1];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|alu[2];
        a=max(a,c);
    }
    for(j=2; j<n; j++)
    {
        b=ara[j];
        for(i=1; i<=k; i++)
        {
            b*=x;
            c=b|alu[i+1]|mara[i-1];
            a=max(a,c);
        }
    }
    b=ara[n];
    for(i=1; i<=k; i++)
    {
        b*=x;
        c=b|mara[n-1];
        a=max(a,c);
    }
    cout<<a<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define pf printf
#define sf scanf
#define ll  long long
#define llu unsigned long long
#define M 200000
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define Check(x,w) (x&(1<<w))==(1<<w)?true:false
#define pii pair<ll,ll>
#define MOD 1000000007
using namespace std;

template<class T>
inline bool fs(T &x)
{
    int c=getchar();
    int sgn=1;
    while(~c&&c<'0'||c>'9')
    {
        if(c=='-')sgn=-1;
        c=getchar();
    }
    for(x=0; ~c&&'0'<=c&&c<='9'; c=getchar())
        x=x*10+c-'0';
    x*=sgn;
    return ~c;
}

ll ara[M+5],mara[M+5],alu[M+5],n,k,x,a;

int main()
{
    fs(n);
    fs(k);
    fs(x);
    int i,j;
    for(i=1; i<=n; i++)
        fs(ara[i]);
    mara[1]=ara[1];
    for(i=2; i<=n; i++)
        mara[i]=mara[i-1]|ara[i];
    alu[n]=ara[n];
    for(i=n-1; i>0; i--)
        alu[i]=alu[i+1]|ara[i];
    ll b,c,d;
    a=0;
    d=1;
    for(i=1; i<=k; i++)
        d*=x;
    c=(ara[1]*d)|alu[2];
    a=max(a,c);
    for(j=2; j<n; j++)
    {
        c=(ara[j]*d)|alu[i+1]|mara[i-1];
        a=max(a,c);
    }
    c=(ara[n]*d)|mara[n-1];
    a=max(a,c);
    cout<<a<<endl;
    return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = k;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	LL ans;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	ans = curr;
	ans = solve(0, k);
	//sort(arr, arr+n, cmp);
	//memset(dp, -1, sizeof dp);
	//ans = max(ans, solve(0, k));
	//random_shuffle(arr,arr+n);
	//memset(dp, -1, sizeof dp);
	//ans = max(ans, solve(0, k));
	//LOG(curr);
	cout << ans << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 0;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	sort(arr, arr+n, cmp);
	//random_shuffle(arr,arr+n);
	//LOG(curr);
	cout << solve(0, k) << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, a[MAXX], b[MAXX];

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	LL ans;
	for(int i = 1;i<=n;i++) cin >> arr[i], curr = curr | arr[i];
	ans = curr;

	for(int i = 1;i<=n;i++) a[i] = a[i-1] | arr[i];
	for(int i = n;i>=1;i--) b[i] = b[i+1] | arr[i];

	LL val = 1;
	for(int i = 0;i<k;i++) val = val * x;
	for(int i = 1;i<=n;i++){
		ans = max(ans, a[i-1] | b[i+1] | val*arr[i]);
	}
	cout << ans << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 0;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	memset(dp, -1, sizeof dp);
	for(int i = 1;i<=n;i++) cin >> arr[i], curr = curr | arr[i];
	random_shuffle(arr+1,arr+n+1);
	//LOG(curr);
	cout << solve(0, k) << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 0;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	LL ans;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	ans = curr;
	ans = solve(0, k);
	sort(arr, arr+n, cmp);
	memset(dp, -1, sizeof dp);
	ans = max(ans, solve(0, k));
	random_shuffle(arr,arr+n);
	memset(dp, -1, sizeof dp);
	ans = max(ans, solve(0, k));
	//LOG(curr);
	cout << ans << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 1;i<=k;i++){
			tt = tt * x;
		}
		for(int i = k;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			//tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	LL ans;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	ans = curr;
	ans = solve(0, k);
	//sort(arr, arr+n, cmp);
	//memset(dp, -1, sizeof dp);
	//ans = max(ans, solve(0, k));
	//random_shuffle(arr,arr+n);
	//memset(dp, -1, sizeof dp);
	//ans = max(ans, solve(0, k));
	//LOG(curr);
	cout << ans << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 0;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	random_shuffle(arr,arr+n);
	//LOG(curr);
	cout << solve(0, k) << endl;
return 0;
}


#include<bits/stdc++.h>

#define IT(a,it) for(auto it=a.begin(); it != a.end(); it++)
#define REV_IT(a,it) for(auto it=a.rbegin(); it != a.rend(); it++)
#define LL long long
#define LD long double
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define INF (int)(1e9)
#define EPS (double)(1e-9)

#ifndef ONLINE_JUDGE
#  define LOG(x) cerr << #x << " = " << (x) << endl
#else
#  define LOG(x) 0
#endif

#define MAXX 500005

using namespace std;

typedef pair <int, int> pi_i;
typedef pair<int, pi_i> pi_ii;

bool cmp(int a, int b){ return a>b; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a * b / gcd(a, b); }

LL n, k, x, arr[MAXX], curr, dp[MAXX][20];

LL solve(int idx, int k){
	if(idx >= n){
		return 0;
	}
	if(dp[idx][k] != -1) return dp[idx][k];
	LL val = arr[idx], ans = val;
	if(k == 0){
		LL tt = val | solve(idx+1, k);
		ans = max(ans, tt);
	}else{
		LL tt = val;
		for(int i = 0;i<=k;i++){
			LL temp = tt | solve(idx+1, k-i);
			ans = max(ans, temp);
			tt = tt * x;
		}
	}
	return dp[idx][k] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	//freopen("out.txt","w",stdout);

	cin >> n >> k >> x;
	memset(dp, -1, sizeof dp);
	for(int i = 0;i<n;i++) cin >> arr[i], curr = curr | arr[i];
	//LOG(curr);
	cout << solve(0, k) << endl;
return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
using namespace std;
int main(){
    ll n,k,x;cin>>n>>k>>x;
    vector<ll> v(n);
    fl(i,0,n) cin>>v[i];
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   ll xx=x;
   fl(i,0,k-1) x*=xx;

         vector<ll> vx(n),vvx(n),res(n);
         vx[1]=v[0];vvx[1]=v[n-1];
         fl(i,2,n) vx[i]=vx[i-1]|v[i-1];
         fl(i,2,n) vvx[i]=vvx[i-1]|v[n-i];
         reverse(vvx.begin(),vvx.end());
         fl(i,0,n) v[i]*=x;
         fl(i,0,n){ res[i]=v[i]|vx[i];res[i]=res[i]|vvx[i];}
         cout<<*max_element(res.begin(),res.end())<<endl;

return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
using namespace std;
int main(){
    ll n,k,x;cin>>n>>k>>x;
    vector<ll> v(n);
    fl(i,0,n) cin>>v[i];
    keep_unique(v);
   reverse(v.begin(),v.end());
   fl(i,0,k-1) x=x*x;
         n=v.size();
         vector<ll> vx(n),vvx(n),res(n);
         vx[1]=v[0];vvx[1]=v[n-1];
         fl(i,2,n) vx[i]=vx[i-1]|v[i-1];
         fl(i,2,n) vvx[i]=vvx[i-1]|v[n-i];
         reverse(vvx.begin(),vvx.end());
         fl(i,0,n) v[i]*=x;
         fl(i,0,n){ res[i]=v[i]|vx[i];res[i]=res[i]|vvx[i];}
         cout<<*max_element(res.begin(),res.end())<<endl;

return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
using namespace std;
int main(){
    ll n,k,x,res=0,o=0;cin>>n>>k>>x;
    vector<ll> v(n);
    fl(i,0,n) cin>>v[i];
    keep_unique(v);
   reverse(v.begin(),v.end());
    if(k>1 || v.size()==1){
        while(k--) v[0]*=x;
        fl(i,0,n) res=res|v[i];
        cout<<res<<endl;
    }
    else{
         n=v.size();   vector<ll> vx(n),vvx(n),res(n);
         vx[1]=v[0];vvx[1]=v[n-1];
         fl(i,2,n) vx[i]=vx[i-1]|v[i-1];
         fl(i,2,n) vvx[i]=vvx[i-1]|v[n-i];
         reverse(vvx.begin(),vvx.end());
         fl(i,0,n) v[i]*=2;
         fl(i,0,n){ res[i]=v[i]|vx[i];res[i]=res[i]|vvx[i];}
         cout<<*max_element(res.begin(),res.end())<<endl;
    }
return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
using namespace std;
int main(){
    ll n,k,x,res=0,o=0;cin>>n>>k>>x;
    vector<ll> v(n);
    fl(i,0,n) cin>>v[i];
    keep_unique(v);
   reverse(v.begin(),v.end());
    if(k>1 || v.size()==1){
        while(k--) v[0]*=x;
        fl(i,0,n) res=res|v[i];
        cout<<res<<endl;
    }
    else{
         n=v.size();   vector<ll> vx(n),vvx(n),res(n);
         vx[1]=v[0];vvx[1]=v[n-1];
         fl(i,2,n) vx[i]=vx[i-1]|v[i-1];
         fl(i,2,n) vvx[i]=vvx[i-1]|v[n-i];
         reverse(vvx.begin(),vvx.end());
         fl(i,0,n) v[i]*=x;
         fl(i,0,n){ res[i]=v[i]|vx[i];res[i]=res[i]|vvx[i];}
         cout<<*max_element(res.begin(),res.end())<<endl;
    }
return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define pb push_back
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define keep_unique(v) sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
using namespace std;
int main(){
    ll n,k,x;cin>>n>>k>>x;
    vector<ll> v(n);
    fl(i,0,n) cin>>v[i];
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   fl(i,0,k-1) x=x*x;
         vector<ll> vx(n),vvx(n),res(n);
         vx[1]=v[0];vvx[1]=v[n-1];
         fl(i,2,n) vx[i]=vx[i-1]|v[i-1];
         fl(i,2,n) vvx[i]=vvx[i-1]|v[n-i];
         reverse(vvx.begin(),vvx.end());
         fl(i,0,n) v[i]*=x;
         fl(i,0,n){ res[i]=v[i]|vx[i];res[i]=res[i]|vvx[i];}
         cout<<*max_element(res.begin(),res.end())<<endl;

return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  unsigned long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
ll a[200001];
ll solve(int K , int i ){
    if( i==n)return (ll)0;
    if (dp[K][i]!=-1)return dp[K][i];
    ll res=(ll) a[i] | (ll)solve( K , i+1 );
    ll xx=x;
    rep(j,K){
        res = max( res, (ll)(xx*a[i])|(ll)solve(K-j-1 , i));
        xx*=x;
    }
    return dp[K][i]=res;
}
int main(){
    fastIO;
    //read;
    memset(dp,-1,sizeof dp);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    cout<<solve( k  , 0)<<endl;
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
ll a[200001];
ll solve(int K , int i ){
    if( i==n)return 0;
    if (dp[K][i]!=-1)return dp[K][i];
    ll res=a[i] | solve( K , i+1 );
    ll xx=x;
    rep(j,K){
        res = max( res, (xx*a[i])|solve(K-j-1 , i+1));
        xx*=x;
    }
    return dp[K][i]=res;
}
int main(){
    fastIO;
   // read;
    memset(dp,-1,sizeof dp);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    cout<<solve( k  , 0)<<endl;
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  unsigned long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
int v[11][200001];
ll a[200001];
ll solve(int K , int i ){
    if( i==n)return 0;
    if (v[K][i]!=-1)return dp[K][i];
    v[K][i]=1;
    ll res=a[i] | solve( K , i+1 );
    ll xx=x;
    rep(j,K){
        res = max( res, (xx*a[i])|solve(K-j-1 , i));
        xx*=x;
    }
    return dp[K][i]=res;
}
int main(){
    fastIO;
  //  read;
    memset(v,-1,sizeof v);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    cout<<solve( k  , 0)<<endl;
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  unsigned long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
ll a[200001];
//ll solve(int K , int i ){
//    if( i==n)return (ll)0;
//    if (dp[K][i]!=-1)return dp[K][i];
//    ll res=(ll) a[i] | (ll)solve( K , i+1 );
//    ll xx=x;
//    rep(j,K){
//        res = max( res, (ll)(xx*a[i])|(ll)solve(K-j-1 , i));
//        xx*=x;
//    }
//    return dp[K][i]=res;
//}
int main(){
    fastIO;
    //read;
    memset(dp,-1,sizeof dp);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    ll res=0;
    rep(i,n-1)res |= a[i];
    rep(i,k)a[n-1]*=x;
    res|=a[n-1];
    cout<<res<<endl;
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
ll a[200001];
ll solve(int K , int i ){
    if( i==n)return 0;
    if (dp[K][i]!=-1)return dp[K][i];
    ll res=a[i] | solve( K , i+1 );
    ll xx=x;
    rep(j,K){
        res = max( res, (xx*a[i])|solve(K-j-1 , i));
        xx*=x;
    }
    return dp[K][i]=res;
}
int main(){
    fastIO;
   // read;
    memset(dp,-1,sizeof dp);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    cout<<solve( k  , 0)<<endl;
    return 0;
}


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include<math.h>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<complex>
#include<math.h>
#include<memory.h>
#include<sstream>
#include<cstdio>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,a,n) for(int i=a;i<n;i++)
#define INF (0x7fffffff)
#define mp make_pair
#define fastIO ios::sync_with_stdio(false)
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define scf(xx) scanf("%d",&xx)
#define All(a) a.begin(), a.end()

typedef  unsigned long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef   double ld;

ll k,x,n;
ll dp[11][200001];
ll a[200001];
//ll solve(int K , int i ){
//    if( i==n)return (ll)0;
//    if (dp[K][i]!=-1)return dp[K][i];
//    ll res=(ll) a[i] | (ll)solve( K , i+1 );
//    ll xx=x;
//    rep(j,K){
//        res = max( res, (ll)(xx*a[i])|(ll)solve(K-j-1 , i));
//        xx*=x;
//    }
//    return dp[K][i]=res;
//}
ll or1[200001],or2[200001];
int main(){
    fastIO;
    //read;
    memset(dp,-1,sizeof dp);
    cin>>n>>k>>x;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    ll res=0;
    or1[0]=a[0];
    or2[n-1]=a[n-1];
    repi(i,1,n)or1[i]=a[i]|or1[i-1];
    for(int i=n-2;i>=0;--i)or2[i]=a[i]|or2[i+1];
    rep(i,n){
        ll y=a[i];
        rep(i,k)y*=x;
        ll t1=0 ,t2=0;
        if( i)t1=or1[i-1];
        if(i<n-1)t2=or2[i+1];
        res=max(res , y|t1|t2);
    }
    cout<<res;
    return 0;
}


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

#define MMS(x) memset(x, 0, sizeof(x))
#define MMS1(x) memset(x, -1, sizeof(x))

using namespace std;

long long q[200010];
int main()
{
    int n,k,i,h;
    long long max=0,x,ans;
    scanf("%d%d%I64d",&n,&k,&x);
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&q[i]);
        if(max<q[i])
        {
           max=q[i];
           h=i;
        }
    }
    while(k--)
    {
        q[h]*=x;
    }
    for(i=0;i<n;i++)
    {
        if(i==0) ans=q[i];
        else ans|=q[i];
    }
    printf("%I64d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

long long n, m, str, fin;
vector <pair <long long, long long> > nei[1010];
vector <pair <long long, long long> > adj[1010];
vector <pair <long long, long long> > cost;

long long dis[1010];

struct cmp
{
	bool operator()(long long x, long long y)
	{
		if(dis[x] != dis[y])
			return dis[x] < dis[y];
		return x < y;
	}
};

set<long long, cmp> s;

void dijkstra(long long s1);

int main()
{
	cin >> n >> m >> str >> fin;
	str --; fin --;
	for(long long i = 0; i < m; ++ i)
	{
		long long u, v, w;
		cin >> u >> v >> w;
		u --; v--;
		nei[u].push_back(make_pair(v, w));
		nei[v].push_back(make_pair(u, w));
	}
	for(long long i = 0; i < n ;++ i)
	{
		long long t, c;
		cin >> t >> c;
		cost.push_back(make_pair(t, c));
	}
	for(long long i = 0; i < n; ++ i)
	{
		dijkstra(i);
		//cout << "~~" << dis[2] << endl;
		for(long long j = 0; j < n; ++ j)
		{
			if(i == j)
				continue;
			if(dis[j] <= cost[i].ff && dis[j] != -1)
				adj[i].push_back(make_pair(j, cost[i].ss));
		}
	}
	s.clear();
	fill(dis, dis + n, -1);
	s.insert(str);
	dis[str] = 0;
	while(!s.empty())
	{
		long long u =* s.begin();
		s.erase(u);
		for(long long i = 0; i < adj[u].size(); ++ i)
		{
			long long x = adj[u][i].ff, y = adj[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
	cout << dis[fin] << endl;
	return 0;
}

void dijkstra(long long s1)
{
	fill(dis, dis + n, -1);
	s.insert(s1);
	dis[s1] = 0;
	while(!s.empty())
	{
		long long u =* s.begin();
		s.erase(u);
		for(long long i = 0; i < nei[u].size(); ++ i)
		{
			long long x = nei[u][i].ff, y = nei[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int n, m, str, fin;
vector <pair <int, int> > nei[1010];
vector <pair <int, int> > adj[1010];
vector <pair <int, int> > cost;

long long dis[1010];

struct cmp
{
	bool operator()(int x, int y)
	{
		if(dis[x] != dis[y])
			return dis[x] < dis[y];
		return x < y;
	}
};

set<int, cmp> s;

void dijkstra(int s1);

int main()
{
	cin >> n >> m >> str >> fin;
	str --; fin --;
	for(int i = 0; i < m; ++ i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		u --; v--;
		nei[u].push_back(make_pair(v, w));
		nei[v].push_back(make_pair(u, w));
	}
	dijkstra(str);
	if(dis[fin] == -1)
	{
		cout << -1 << endl;
		return 0;
	}
	for(int i = 0; i < n ;++ i)
	{
		int t, c;
		cin >> t >> c;
		cost.push_back(make_pair(t, c));
	}
	for(int i = 0; i < n; ++ i)
	{
		for(int j = 0; j < n; ++ j)
		{
			if(i == j)
				continue;
			if(dis[j] <= cost[i].ff)
				adj[i].push_back(make_pair(j, cost[i].ss));
		}
	}
	s.clear();
	fill(dis, dis + n, -1);
	s.insert(str);
	dis[str] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < adj[u].size(); ++ i)
		{
			int x = adj[u][i].ff, y = adj[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
	cout << dis[fin] << endl;
	return 0;
}

void dijkstra(int s1)
{
	fill(dis, dis + n, -1);
	s.insert(s1);
	dis[s1] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < nei[u].size(); ++ i)
		{
			int x = nei[u][i].ff, y = nei[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int n, m, str, fin;
vector <pair <int, int> > nei[1010];
vector <pair <int, int> > adj[1010];
vector <pair <int, int> > cost;

long long dis[1010];

struct cmp
{
	bool operator()(int x, int y)
	{
		if(dis[x] != dis[y])
			return dis[x] < dis[y];
		return x < y;
	}
};

set<int, cmp> s;

void dijkstra(int s1);

int main()
{
	cin >> n >> m >> str >> fin;
	str --; fin --;
	for(int i = 0; i < m; ++ i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		u --; v--;
		nei[u].push_back(make_pair(v, w));
		nei[v].push_back(make_pair(u, w));
	}
	for(int i = 0; i < n ;++ i)
	{
		int t, c;
		cin >> t >> c;
		cost.push_back(make_pair(t, c));
	}
	for(int i = 0; i < n; ++ i)
	{
		dijkstra(i);
		//cout << "~~" << dis[2] << endl;
		for(int j = 0; j < n; ++ j)
		{
			if(i == j)
				continue;
			if(dis[j] <= cost[i].ff && dis[j] != -1)
				adj[i].push_back(make_pair(j, cost[i].ss));
		}
	}
	s.clear();
	fill(dis, dis + n, -1);
	s.insert(str);
	dis[str] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < adj[u].size(); ++ i)
		{
			int x = adj[u][i].ff, y = adj[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
	cout << dis[fin] << endl;
	return 0;
}

void dijkstra(int s1)
{
	fill(dis, dis + n, -1);
	s.insert(s1);
	dis[s1] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < nei[u].size(); ++ i)
		{
			int x = nei[u][i].ff, y = nei[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int n, m, str, fin;
vector <pair <int, int> > nei[1010];
vector <pair <int, int> > adj[1010];
vector <pair <int, int> > cost;

long long dis[1010];

struct cmp
{
	bool operator()(int x, int y)
	{
		if(dis[x] != dis[y])
			return dis[x] < dis[y];
		return x < y;
	}
};

set<int, cmp> s;

void dijkstra(int s1);

int main()
{
	cin >> n >> m >> str >> fin;
	str --; fin --;
	for(int i = 0; i < m; ++ i)
	{
		int u, v, w;
		cin >> u >> v >> w;
		u --; v--;
		nei[u].push_back(make_pair(v, w));
		nei[v].push_back(make_pair(u, w));
	}
	for(int i = 0; i < n ;++ i)
	{
		int t, c;
		cin >> t >> c;
		cost.push_back(make_pair(t, c));
	}
	for(int i = 0; i < n; ++ i)
	{
		dijkstra(i);
		for(int j = 0; j < n; ++ j)
		{
			if(i == j)
				continue;
			if(dis[j] <= cost[i].ff)
				adj[i].push_back(make_pair(j, cost[i].ss));
		}
	}
	s.clear();
	fill(dis, dis + n, -1);
	s.insert(str);
	dis[str] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < adj[u].size(); ++ i)
		{
			int x = adj[u][i].ff, y = adj[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
	cout << dis[fin] << endl;
	return 0;
}

void dijkstra(int s1)
{
	fill(dis, dis + n, -1);
	s.insert(s1);
	dis[s1] = 0;
	while(!s.empty())
	{
		int u =* s.begin();
		s.erase(u);
		for(int i = 0; i < nei[u].size(); ++ i)
		{
			int x = nei[u][i].ff, y = nei[u][i].ss + dis[u];
			if(dis[x] != -1 && dis[x] <= y)
				continue;
			s.erase(x);
			dis[x] = y;
			s.insert(x);
		}
	}
}


/* Author : RISHAV GOYAL */

#include <bits/stdc++.h>

using namespace std;

#define LL long long int
#define UL unsigned long long int

#define imax INT_MAX
#define imin INT_MIN
#define LLmax LLONG_MAX
#define LLmin LLONG_MIN

#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)
#define rep(i,n) for(int i= int(1); i<= (int)n; i++)
#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)

#define pr() printf("Reached here 1...\n");
#define pr1() printf("Reached here 2...\n");

#define CLR(a) memset(a,0,sizeof(a));
#define SET(a) memset(a,-1,sizeof(a));

#define str strlen
#define pb(x) push_back(x)
#define mp make_pair
#define ii pair<int,int>
#define F first
#define S second
#define gcd(a,b) __gcd(a,b)

#define mod int(1e9 +7)
#define MAX int(1e5 + 10)

#define si(a) scanf("%d",&a);

#define VI vector<int>
#define VL vector<LL>
#define VS vector<string>
#define VC vector<char>

LL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}

int n,m,x,y,u,v,vertex,t[1010],c[1010],w,sz[1010]={0},visited[1010]={0};
LL dp[1010][1010],dpCost[1010];
std::vector<ii> edge[1010];
VI ToReach[1010];

int main()
{
	SET(dp);
	cin >> n >> m >> x >> y;
	rep(i,m){
		cin >> u >> v >> w;
		edge[u].pb(mp(v,w));
		edge[v].pb(mp(u,w));
		sz[u]++; sz[v]++;
	}
	rep(i,n) cin >> t[i] >> c[i];

	for(int i=1;i<=n;++i){
		priority_queue<pair<LL,int>,vector <pair<LL,int> > > Q;
		Q.push(mp(0,i));
		dp[i][i] = 0;

		CLR(visited);

		while(1){
			vertex = -1;
			while(!Q.empty()){
				if(!visited[Q.top().S]){
					vertex = Q.top().S;
					Q.pop();
					break;
				}
				Q.pop();
			}
			if(vertex == -1) break;
			visited[vertex] = 1;
			for(int j=0;j<sz[vertex];++j) {
				if(dp[i][edge[vertex][j].F]!=-1) dp[i][edge[vertex][j].F] = min(dp[i][edge[vertex][j].F], edge[vertex][j].S + dp[i][vertex]);
				else dp[i][edge[vertex][j].F] = edge[vertex][j].S + dp[i][vertex];
				Q.push(mp(-dp[i][edge[vertex][j].F], edge[vertex][j].F));
			}
		}
	}

	CLR(visited);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(dp[i][j] == -1) dp[i][j] = 1e16L;
			if(dp[i][j]<=t[i]){
				ToReach[i].pb(j);
			}
		}
	}

	priority_queue<pair<LL,int>,vector <pair<LL,int> > > Heap;
	Heap.push(mp(0,x));
	SET(dpCost);
	dpCost[x]=0;
	while(1){
		vertex = - 1;
		while(!Heap.empty()){
			if( !visited[Heap.top().S] ){
				vertex = Heap.top().S ;
				Heap.pop();
				break;
			}
			Heap.pop();
		}
		if(vertex == -1) break;
		if(vertex == y) break;
		visited[vertex] = 1;

		for(int j=0;j<ToReach[vertex].size();++j) {
			if(dpCost[ToReach[vertex][j]]!=-1) dpCost[ToReach[vertex][j]] = min(dpCost[ToReach[vertex][j]], dpCost[vertex] + c[vertex]);
			else dpCost[ToReach[vertex][j]] = dpCost[vertex] + c[vertex];
			Heap.push(mp(-dpCost[ToReach[vertex][j]], ToReach[vertex][j]));
		}

	}
	if(dpCost[y] == -1) cout<<-1<<endl;
	else cout<<dpCost[y]<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define next DALSHE
const int N=1333;
using namespace std;
#define int long long
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
int d[N],ss,tt,n,m,x,tim,coss,y,z;
const int inf=1e17;
pair<int,int> tmp;
int v;
vector<int> g[N],c[N],gg[N],cc[N];
void deikstra(int st){
    q.push(mp(0,st));
    for(int i=1;i<=n;++i)
        d[i]=inf;
    d[st]=0;
    while(!q.empty()){
        tmp=q.top();
        q.pop();
        v=tmp.second;
       // cout<<v<<endl;
        if(d[v]!=tmp.first)continue;
        for(int i=0;i<g[v].size();++i){
            if(d[v]+c[v][i]<d[g[v][i]]){
                d[g[v][i]]=d[v]+c[v][i];
                q.push(mp(d[g[v][i]],g[v][i]));
            }
        }
    }
}
void super_deikstra(int st){
    q.push(mp(0,st));
    for(int i=1;i<=n;++i)
        d[i]=inf;
    d[st]=0;
    while(!q.empty()){
        tmp=q.top();
        q.pop();
        v=tmp.second;
        if(d[v]!=tmp.first)continue;
        for(int i=0;i<gg[v].size();++i){
            if(d[v]+cc[v][i]<d[gg[v][i]]){
                d[gg[v][i]]=d[v]+cc[v][i];
                q.push(mp(d[gg[v][i]],gg[v][i]));
            }
        }
    }
}
main(){
    cin.tie(NULL);ios_base::sync_with_stdio(false);
    cin>>n>>m>>ss>>tt;
    for(int i=1;i<=m;++i){
        cin>>x>>y>>z;
        g[x].pb(y);
        g[y].pb(x);
        c[x].pb(z);
        c[y].pb(z);
    }
    for(int i=1;i<=n;++i){
        cin>>tim>>coss;
        deikstra(i);
        for(int j=1;j<=n;++j)
        if(d[j]<=tim){
            gg[i].pb(j);
            cc[i].pb(coss);
           // gg[j].pb(i);
           // cc[j].pb(cos);
        }
    }
    super_deikstra(ss);
    if(d[tt]==inf)d[tt]=-1;
    cout<<d[tt];
}