#include <bits/stdc++.h>
using namespace std;
void loadData(void);
int proc(void);
void printRes(int);
char input[1001];
string s1, s2;
int k;
long long dp[100001][2];
int getCutPos(void);
bool ok(int pos);
int main(int argc, char** argv) {
  loadData();
  printRes(proc());
  return 0;
}
bool ok(int pos) {
  for (int i = 0; i < s1.size(); i++)
    if (s1[i] != s2[(pos + i) % s2.size()]) return false;
  return true;
}
int getCutPos(void) {
  int res = 0;
  for (int i = 0; i < s2.size(); i++)
    if (ok(i)) res++;
  return res;
}
int proc(void) {
  if (k == 0) return s1 == s2 ? 1 : 0;
  long long cutpos = (long long)getCutPos();
  if (cutpos == (long long)0) return 0;
  dp[1][0] = (long long)((s1 == s2) ? cutpos - (long long)1 : cutpos);
  dp[1][1] = (long long)((long long)s1.size() - (long long)1 - dp[1][0]);
  for (int i = 2; i <= k; i++) {
    dp[i][0] = ((dp[i - 1][0] * ((long long)(cutpos - (long long)1))) %
                    ((long long)1000000007) +
                (dp[i - 1][1] * cutpos) % ((long long)1000000007)) %
               ((long long)1000000007);
    dp[i][1] = (dp[i - 1][0] + dp[i - 1][1]) * ((long long)(s1.size() - 1)) %
                   ((long long)1000000007) -
               dp[i][0];
    if (dp[i][1] < (long long)0) dp[i][1] += ((long long)1000000007);
  }
  return (int)dp[k][0];
}
void loadData(void) {
  char enter;
  scanf("%s%c", input, &enter);
  s1 = input;
  scanf("%s%c", input, &enter);
  s2 = input;
  scanf("%d%c", &k, &enter);
  return;
}
void printRes(int res) {
  printf("%d\n", res);
  return;
}
