#include <bits/stdc++.h>
using namespace std;
int N, a[200005], b[200005], ans[200005];
int main() {
  int n, m, p;
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  if (n <= p) {
    if (m != 1)
      printf("0\n");
    else {
      N = 0;
      for (int i = 1; i <= n; i++) {
        if (b[1] == a[i]) {
          ans[N++] = i;
        }
      }
      printf("%d\n", N);
      for (int i = 0; i < N; i++) printf("%d ", ans[i]);
      printf("\n");
    }
  } else {
    N = 0;
    int k = 0;
    map<int, int> mp;
    mp.clear();
    for (int i = 1; i <= m; i++) {
      if (mp.count(b[i]) == 0) k++;
      mp[b[i]] = 0;
    }
    for (int i = 1; i <= m; i++) mp[b[i]]++;
    map<int, int> mt;
    for (int i = 1; i <= p; i++) {
      mt.clear();
      int t = (n - i) / p;
      if (t + 1 < m) continue;
      int ok = 0;
      for (int j = 0; j <= m - 1; j++) {
        int v = a[i + j * p];
        if (mp.count(v) == 0) continue;
        if (mt[v] == mp[v] - 1)
          ok++;
        else if (mt[v] == mp[v])
          ok--;
        mt[v]++;
      }
      if (ok == k) ans[N++] = i;
      for (int j = m; j <= t; j++) {
        int u = a[i + (j - m) * p], v = a[i + j * p];
        if (u != v) {
          if (mp.count(u) != 0) {
            if (mt[u] == mp[u] + 1)
              ok++;
            else if (mt[u] == mp[u])
              ok--;
            mt[u]--;
          }
          if (mp.count(v) != 0) {
            if (mt[v] == mp[v] - 1)
              ok++;
            else if (mt[v] == mp[v])
              ok--;
            mt[v]++;
          }
        }
        if (ok == k) {
          ans[N++] = i + (j - m + 1) * p;
        }
      }
    }
    sort(ans, ans + N);
    printf("%d\n", N);
    for (int i = 0; i < N; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
