#include <bits/stdc++.h>
using namespace std;
const int MOD = (1e9) + 7;
string s, t;
int k, good;
long long ans, dp[100001][2];
int main() {
  cin >> s >> t >> k;
  dp[0][0] = 1;
  for (int i = 0; i < s.length(); i++) {
    bool valid = true;
    int p = 0;
    for (int j = i; j < s.length(); j++) valid &= s[j] == t[p++];
    for (int j = 0; j < i; j++) valid &= s[j] == t[p++];
    if (valid) {
      if (!i) dp[0][0] = 0, dp[0][1] = 1;
      good++;
    }
  }
  for (int i = 1; i <= k; i++) {
    dp[i][0] = ((s.length() - good) * dp[i - 1][1] +
                (s.length() - good - 1) * dp[i - 1][0]) %
               MOD;
    dp[i][1] = (good * dp[i - 1][0] + (good - 1) * dp[i - 1][1]) % MOD;
  }
  printf("%lld", dp[k][1]);
}
