#include <bits/stdc++.h>
using namespace std;
int ch[1001000], s[210];
int n, haveans, la, lb;
int ret[2010], ans[2010];
bool solve(int w, int x, int y, int z) {
  if (w > la && y > lb) return 1;
  if (w > la || y > lb) return 0;
  if (ch[w] != s[y]) return 0;
  return solve(w + x, x, y + z, z);
}
bool check() {
  for (int i = 1; i <= n; i++)
    if (ret[i] < ans[i])
      return 1;
    else if (ret[i] > ans[i])
      return 0;
  return 0;
}
int main() {
  int c = getchar();
  while (c != '\n') {
    ch[++la] = c;
    c = getchar();
  }
  c = getchar();
  while (c != '\n') {
    s[++lb] = c;
    c = getchar();
  }
  scanf("%d", &n);
  for (int i = 1; i <= min(n, lb); i++) {
    int tmp = i;
    if (la / n * i > lb) continue;
    if ((la / n + 1) * i < lb) continue;
    memset(ret, 0, sizeof(ret));
    for (int j = n; j; j--) {
      if (solve(j, n, tmp, i)) ret[j] = 1, tmp--;
      if (!tmp) break;
    }
    if (!tmp && (check() || !haveans)) {
      for (int j = 1; j <= n; j++) ans[j] = ret[j];
      haveans = 1;
    }
  }
  if (!haveans)
    printf("0\n");
  else
    for (int i = 1; i <= n; i++) printf("%d", ans[i]);
  return 0;
}
