#include <bits/stdc++.h>
using namespace std;
int A[2][1010], T[2];
char S[1010], E[1010];
int main() {
  int i, j, m, n, k, p;
  char ch;
  int MOD = 1000000007;
  do {
    scanf("%c", &ch);
  } while ((ch < 'a') && (ch > 'z'));
  n = 0;
  do {
    S[n] = ch;
    n++;
    scanf("%c", &ch);
  } while ((ch >= 'a') && (ch <= 'z'));
  do {
    scanf("%c", &ch);
  } while ((ch < 'a') && (ch > 'z'));
  n = 0;
  do {
    E[n] = ch;
    n++;
    scanf("%c", &ch);
  } while ((ch >= 'a') && (ch <= 'z'));
  scanf("%d", &k);
  memset(A[0], 0, sizeof(A[0]));
  A[0][0] = 1;
  p = 0;
  T[0] = MOD + 1;
  for (j = 0; j < k; j++) {
    p = 1 - p;
    T[p] = 0;
    for (i = 0; i < n; i++) {
      A[p][i] = (T[1 - p] - A[1 - p][i]) % MOD;
      T[p] = (T[p] + A[p][i]) % MOD;
    }
    T[p] += MOD;
  }
  int ans = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++)
      if (E[(i + j) % n] != S[j]) break;
    if (j == n) ans = (ans + A[p][i]) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}
