#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int mod = 1000000007;
const int N = 10001;
const int M = 331;
int n, k, h, b, c, d, p[10005], pw[10005], dp[10005], pd[10005];
string s, t;
void add(int &a, int b) {
  a += b;
  if (mod <= a) a -= mod;
}
int get(int l, int r) {
  int x = (p[r] - p[l - 1]);
  if (x < 0) x += mod;
  return ((long long)x * pw[N - l]) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout.precision(30);
  cerr.precision(7);
  ;
  cin >> s >> t >> k;
  n = (int)s.size();
  s = "#" + s + s;
  t = "#" + t;
  pw[0] = pd[0] = b = 1;
  for (int i = 1; i <= N; i++) {
    pw[i] = ((long long)pw[i - 1] * M) % mod;
    if (i <= n + n)
      p[i] = ((long long)p[i - 1] + (long long)pw[i] * (long long)s[i]) % mod;
    if (i <= n) h = ((long long)h + (long long)pw[i] * (long long)t[i]) % mod;
  }
  h = ((long long)h * (long long)pw[N - 1]) % mod;
  for (int i = 1; i <= k; i++) {
    for (int j = 0; j < n; j++) {
      dp[j] = (b - pd[j] + mod) % mod;
      add(c, dp[j]);
    }
    for (int j = 0; j < n; j++) pd[j] = dp[j], dp[j] = 0;
    b = c;
    c = 0;
  }
  for (int i = 0; i < n; i++)
    d = (d + ((get(i + 1, n + i) == h) * pd[i])) % mod;
  cout << d;
  return 0;
}
