#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxp = (int)1e6 + 10;
const int maxs = 222;
const int maxk = 2222;
char p[maxp], s[maxs];
int best[maxk], cur[maxk];
int main() {
  gets(p);
  gets(s);
  int n = strlen(p);
  int m = strlen(s);
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    best[i] = 1;
  }
  bool wasAns = false;
  for (int cnt = 1; cnt <= k && cnt <= m; cnt++) {
    if ((n / k + 1) * cnt < m) continue;
    if (n / k * cnt > m) break;
    int curcnt = cnt;
    memset(cur, 0, sizeof(cur));
    for (int i = k - 1; i >= 0 && curcnt > 0; i--) {
      int r = i;
      int e = curcnt - 1;
      bool same = true;
      while (r < n && e < m && same) {
        if (p[r] != s[e]) same = false;
        r += k;
        e += cnt;
      }
      same &= r >= n && e >= m;
      if (same) {
        cur[i] = 1;
        curcnt--;
      } else {
        cur[i] = 0;
      }
    }
    if (curcnt) continue;
    wasAns = true;
    bool better = false;
    for (int i = 0; i < k; i++) {
      if (cur[i] > best[i]) break;
      if (cur[i] < best[i]) {
        better = true;
        break;
      }
    }
    if (!better) continue;
    for (int i = 0; i < k; i++) {
      best[i] = cur[i];
    }
  }
  if (!wasAns) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < k; i++) {
    printf("%d", best[i]);
  }
  return 0;
}
