#include <bits/stdc++.h>
using namespace std;
void fast_stream() { std::ios_base::sync_with_stdio(0); }
const int mod = 1000000007;
int dp[2][1001];
bool match[1001];
void solve() {
  string s, g;
  cin >> s;
  cin >> g;
  int k;
  int len = s.size();
  cin >> k;
  if (k == 0) {
    if (s == g)
      cout << 1 << endl;
    else
      cout << 0 << endl;
    return;
  }
  bool okk = false;
  for (int i = 0; i < len; i++) {
    bool ok = true;
    for (int j = 0; j < len; j++) {
      if (s[j] != g[(i + j) % len]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      okk = true;
      match[i] = true;
    }
  }
  if (!okk) {
    cout << 0 << endl;
    return;
  }
  long long sum = 0;
  for (int i = k; i >= 0; i--) {
    int cur = i % 2;
    int nxt = (i + 1) % 2;
    long long nsum = 0;
    for (int j = 0; j < len; j++) {
      int res = 0;
      if (i == k) {
        if (match[j]) res = 1;
      } else {
        res = sum;
        sum -= dp[nxt][(j + 1) % len];
        sum += dp[nxt][(len + j) % len];
      }
      dp[cur][j] = res % mod;
      if (j >= 1) nsum = (nsum + res);
    }
    sum = nsum % mod;
  }
  cout << dp[0][0] % mod << endl;
}
int main() {
  solve();
  return 0;
}
