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

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

template<typename T, T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD; if(v<0) v += MOD;}

  Mint pow(long long k){
    Mint res(1), tmp(v);
    while(k){
      if(k & 1) res *= tmp;
      tmp *= tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD - 2);}

  Mint& operator +=(Mint a){v+=a.v; if(v>=MOD) v-= MOD; return *this;}
  Mint& operator -=(Mint a){v+=MOD-a.v; if(v>=MOD) v-= MOD; return *this;}
  Mint& operator *=(Mint a){v = 1LL * v * a.v%MOD; return *this;}
  Mint& operator /=(Mint a){return (*this) *= a.inv();}

  Mint operator+(Mint a)const{return Mint(v)+=a;}
  Mint operator-(Mint a)const{return Mint(v)-=a;}
  Mint operator*(Mint a)const{return Mint(v)*=a;}
  Mint operator/(Mint a)const{return Mint(v)/=a;}

  Mint operator-()const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator<(const Mint a)const{return v<a.v;}

  static Mint comb(long long n, Int k){
    Mint num(1), dom(1);
    for(Int i=0;i<k;i++){
      num *= Mint(n - i);
      dom *= Mint(i + 1);
    }
    return num / dom;
  }
};

template<typename T, T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T, T MOD>
ostream& operator<<(ostream &os, Mint<T, MOD> m){os<<m.v;return os;}

struct UnionFind{
  Int num;
  vector<Int> r, p;
  UnionFind(){}
  UnionFind(Int n):num(n), r(n, 1), p(n, 0){iota(p.begin(), p.end(), 0);}

  Int find(Int x){
    return (x == p[x]? x:p[x]=find(p[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;
    if(r[x] < r[y]) swap(x, y);
    r[x] += r[y];
    p[y] = x;
    num--;
  }

  Int size(Int x){return r[find(x)];}
  Int count()const{return num;}
};


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string Z,O;
  Int n;
  cin>>Z>>O>>n;

  Int P=Z.size();
  Int Q=O.size();

  Int len=n+P+n+Q;

  using M = Mint<Int>;

  const Int BS = 1e6;
  if(n<BS){
    UnionFind uf(len);
    for(Int i=0;i<len;i++)
      uf.unite(i,len-(i+1));
    for(Int i=0;i<n;i++)
      uf.unite(i,n+P+i);

    vector<char> cs(len,'#');
    for(Int i=0;i<P;i++){
      Int k=uf.find(n+i);
      if(cs[k]=='#') cs[k]=Z[i];
      if(cs[k]!=Z[i]) drop(0);
    }

    for(Int i=0;i<Q;i++){
      Int k=uf.find(n+P+n+i);
      if(cs[k]=='#') cs[k]=O[i];
      if(cs[k]!=O[i]) drop(0);
    }

    M res{1};
    for(Int i=0;i<len;i++){
      if(uf.find(i)!=i) continue;
      if(cs[i]=='#') res*=M(26);
    }

    cout<<res<<endl;
    return 0;
  };

  if(P>=Q){
    if(Z.substr(0,Q)!=O) drop(0);
    string S=Z.substr(Q);
    string T=S;
    reverse(T.begin(),T.end());
    if(S!=T) drop(0);
  }else{
    if(O.substr(0,P)!=Z) drop(0);
    string S=O.substr(P);
    string T=S;
    reverse(T.begin(),T.end());
    if(S!=T) drop(0);
  }

  cout<<M(26).pow((n-Q+1)/2)<<endl;
  return 0;
}



Measured memory_bytes: 10188