#include <bits/stdc++.h>
const double eps = 1e-9;
const int int_inf = 2000000000;
const long long i64_inf = 1000000000000000000LL;
const double pi = acos(-1.0);
const long long mod = 1000000007;
using namespace std;
string fr;
string to;
string second;
int k;
vector<int> r;
int c[2000][2000];
int d[2][2200];
int sum;
void build() {
  int n = (int)second.length();
  int p[n + 10];
  p[0] = 0;
  int len = (int)to.length();
  int l = (int)fr.length();
  for (int i = 1; i < n; i++) {
    int j = p[i - 1];
    while (j > 0 && second[j] != second[i]) j = p[j - 1];
    if (second[i] == second[j]) j++;
    p[i] = j;
    if (p[i] == len && i - l - len < len) r.push_back(i - l - len);
  }
}
int main() {
  getline(cin, fr);
  getline(cin, to);
  cin >> k;
  if (k == 0) {
    if (fr == to)
      cout << "1" << endl;
    else
      cout << "0" << endl;
    return 0;
  }
  second = to + "#" + fr + fr;
  build();
  int ans = 0;
  memset(d, 0, sizeof(d));
  int len = (int)fr.length();
  int g = 0;
  int second;
  d[g][0] = second = 0;
  for (int i = 1; i < len; i++) {
    d[g][i] = 1ll;
    second = (second + d[g][i]) % mod;
  }
  for (int K = 2; K <= k; K++) {
    sum = second;
    second = 0;
    g = 1 - g;
    for (int i = 0; i < len; i++)
      d[g][i] = (sum - d[1 - g][i] + mod) % mod,
      second = (second + d[g][i]) % mod;
  }
  for (int i = 0; i < (int)r.size(); i++) ans = (ans + d[g][r[i]]) % mod;
  cout << ans << endl;
  return 0;
}
