#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n){return (n==0) ? 1 : 10 * TEN(n-1);}
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,N) for(int i=0;i<(int)(N);i++)
#define rep1(i,N) for(int i=1;i<=(int)(N);i++)
#define fs first
#define sc second
#define eb emplace_back
#define pb eb
#define all(x) x.begin(),x.end()
template<class T, class U> void chmin(T& t, const U& u){ if(t>u) t = u;}
template<class T, class U> void chmax(T& t, const U& u){ if(t<u) t = u;}

#ifdef LOCAL
#define show(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template<class T,class U>
ostream& operator<<(ostream& os, const pair<T,U>& p){
    return os << "P(" << p.fs << ", " << p.sc << ")";
}
template<class T> ostream& operator<<(ostream& os, const V<T>& v){
    os << "[";
    for(auto d: v) os << d << ", ";
    return os << "]";
}
template<unsigned int mod_>
struct ModInt{
    using M = ModInt;
    constexpr static uint mod = mod_;
    uint v;
    ModInt():v(0){}
    ModInt(ll _v):v(normS(_v%mod+mod)){}
    explicit operator bool() const {return v!=0;}
    static uint normS(const uint&x){return (x<mod)?x:x-mod;}
    static M make(const uint&x){M m;m.v=x;return m;}
    M operator+(const M& b) const {return make(normS(v+b.v));}
    M operator-(const M& b) const {return make(normS(v+mod-b.v));}
    M operator-() const {return make(normS(mod-v));}
    M operator*(const M& b) const {return make((ull)v*b.v%mod);}
    M operator/(const M& b){return *this*b.inv();}
    M& operator+=(const M& b){return *this=*this+b;}
    M& operator-=(const M& b){return *this=*this-b;}
    M& operator*=(const M& b){return *this=*this*b;}
    M& operator/=(const M& b){return *this=*this/b;}
    ll extgcd(ll a,ll b,ll &x,ll& y) const {
        ll p[]={a,1,0},q[]={b,0,1};
        while(*q){
            ll t=*p/ *q;
            rep(i,3) swap(p[i]-=t*q[i],q[i]);
        }
        if(p[0]<0) rep(i,3) p[i] = -p[i];
        x = p[1], y = p[2];
        return p[0];
    }
    ModInt inv() const {
        ll x,y;
        extgcd(v,mod,x,y);
        return make(normS(x+mod));
    }
    M pow(ll p) const {
        if(p<0) return inv().pow(-p);
        M a = 1;
        M x = *this;
        while(p){
            if(p&1) a *= x;
            x *= x;
            p /= 2;
        }
        return a;
    }
    bool operator==(const M& b) const {return v == b.v;}
    bool operator!=(const M& b) const {return v != b.v;}
    friend ostream& operator<<(ostream &o, const M& x){return o<<x.v;}
};
using mint = ModInt<1000000007>;
struct UnionFind{
    V<int> par;
    UnionFind(int N){
        par.assign(N,0);
        rep(i,N) par[i] = i;
    }
    int find(int x){
        if(par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        par[y] = x;
    }
};

int test(int a,int b,int N){
    UnionFind UF(N+1);
    V<int> v;
    rep(i,N) v.pb(i);
    rep(i,a) v.pb(N);
    rep(i,N) v.pb(i);
    rep(i,b) v.pb(N);
    int L = v.size();
    rep(i,L) UF.unite(v[i],v[L-1-i]);
    int r = 0;
    rep(i,N+1) if(UF.find(i) == i){
        if(!UF.same(i,N)) r++;
    }
    return r;
}
int test2(string a,string b,int N){
    int A = a.size(), B = b.size();
    UnionFind UF(N+1);
    V<int> v;
    rep(i,N) v.pb(i);
    rep(i,A) v.pb(N);
    rep(i,N) v.pb(i);
    rep(i,B) v.pb(N);
    int L = v.size();
    rep(i,L) UF.unite(v[i],v[L-1-i]);
    int r = 0;
    rep(i,N+1) if(UF.find(i) == i){
        if(!UF.same(i,N)) r++;
    }

    {
        UnionFind UF2(L);
        rep(i,L) UF2.unite(i,L-1-i);
        rep(i,N) UF2.unite(i,N+A+i);
        V<int> s(L);
        rep(i,A) s[N+i] |= 1<<(a[i]-'a');
        rep(i,B) s[N+A+N+i] |= 1<<(b[i]-'a');
        rep(i,L){
            s[UF2.find(i)] |= s[i];
        }
        rep(i,L){
            if(__builtin_popcount(s[i]) > 1) return -1;
        }
    }
    
    return r;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    // while(true){
    //     int a,b;
    //     cin >> a >> b;
    //     const int X = TEN(6);
    //     for(int N=X;N<X+100;N++){
    //         cout << N << " : " << test(a,b,N) << endl;
    //     }
    // }

    string a,b;
    ll N;
    cin >> a >> b >> N;
    int r = -1;
    const ll X = TEN(6);
    if(N <= X+100){
        r = test2(a,b,N);
    }else{
        int r0 = test2(a,b,X+N%2);
        int r1 = test2(a,b,X+N%2+2);
        show(r0);
        show(r1);
        r = r0 + (r1-r0) * ((N-X)/2);
    }
    show(r);
    if(r == -1){
        cout << 0 << endl;
    }else{
        cout << mint(26).pow(r) << endl;
    }
}


Measured memory_bytes: 40740