#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<numeric>
#include<algorithm>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)

#define mod 1000000007

int  mod_pow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    if(b%2==0){
        int k = mod_pow(a,b/2);
        return k*k%mod;
    }else{
        int k = mod_pow(a,b/2);
        k *= k;
        k%= mod;
        return k*a%mod;
    }
}

class UnionFind{
private:
    int sz;
    vector<int> par,nrank;
public:
    UnionFind(){}
    UnionFind(int node_size) :sz(node_size),par(sz),nrank(sz,0){
        iota(par.begin(),par.end(),0);
    }
    int find(int x){
        if(par[x]==x)return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x),y = find(y);
        if(x==y)return ;
        if(nrank[x] < nrank[y]) swap(x,y);
        par[y] = x;
        if(nrank[x] == nrank[y]) nrank[x]++;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
};


signed main(){
    string b,c;
    int L;
    cin >> b >> c >> L;
    int B = b.size();
    int C = c.size();
    int n = 2*L+B+C;
    
    if(L<=300000){
        vector<char> s(n,'X');
        vector<char> t(n);
        rep(i,B){
            s[i+L] = b[i];
        }
        rep(i,C){
            s[i+L+L+B] = c[i];
        }
        UnionFind uf(n);
        rep(i,n){
            t[i] = s[i];
        }
        
        rep(i,n){
            if(i==n-1-i)continue;
            if(!uf.same(i,n-1-i)){
                if(t[uf.find(i)]=='X'){
                    char p = t[uf.find(n-1-i)];
                    t[uf.find(i)] = p;
                    t[uf.find(n-1-i)] = p;
                    uf.unite(i,n-1-i);
                }else if(t[uf.find(n-1-i)]=='X'){
                    char p = t[uf.find(i)];
                    t[uf.find(i)] = p;
                    t[uf.find(n-1-i)] = p;
                    uf.unite(i,n-1-i);
                }else{
                    if(t[uf.find(i)]!=t[uf.find(n-1-i)]){
                        cout << 0 << endl;
                        return 0;
                    }else{
                        uf.unite(i,n-1-i);
                    }
                }
            }
        }
        rep(i,L){
            if(!uf.same(i,i+L+B)){
                if(t[uf.find(i)]=='X'){
                    char p = t[uf.find(i+L+B)];
                    t[uf.find(i)] = p;
                    t[uf.find(i+L+B)] = p;
                    uf.unite(i,i+L+B);
                }else if(t[uf.find(i+L+B)]=='X'){
                    char p = t[uf.find(i)];
                    t[uf.find(i)] = p;
                    t[uf.find(i+L+B)] = p;
                    uf.unite(i,i+L+B);
                }else{
                    if(t[uf.find(i)]!=t[uf.find(i+L+B)]){
                        cout << 0 << endl;
                        return 0;
                    }else{
                        uf.unite(i,i+L+B);
                    }
                }
            }
        }
        vector<int> cc(n);
        rep(i,L){
            if(t[uf.find(i)]=='X'){
                //cerr << i << endl;
                cc[uf.find(i)] = 1;
            }
        }
        int sm = 0;
        rep(i,n){
            sm += cc[i];
        }
        cout << mod_pow(26,sm) << endl;
    }else{
        int len = L-C;
        len = (len+1)/2;
        if(B==C){
            if(b==c){
                cout << mod_pow(26,len) << endl;
            }else{
                cout << 0 << endl;
            }

        }else if(B>C){
            
            rep(i,C){
                if(b[i]!=c[i]){
                    cout << 0 << endl;
                    return 0;
                }
            }
            for(int i = C;i<B;i++){
                if(b[i]!=b[B+C-1-i]){
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << mod_pow(26,len) << endl;
        }else{
            
            rep(i,B){
                if(b[i]!=c[i]){
                    cout << 0 << endl;
                    return 0;
                }
            }
            for(int i = B;i<C;i++){
                if(c[i]!=c[B+C-1-i]){
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << mod_pow(26,len) << endl;

        }
    }
    return 0;
}


Measured memory_bytes: 10316