#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ll long long
#define ld long double
#define vi   vector<int>
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v)  ((int)((v).size()))
#define all(v) ((v).begin()),((v).end())
#define MEM(dp,i) memset(dp ,i, sizeof (dp))
#define repit( cont , i  ) for( auto i : cont)
#define forr(c,x,n)   for(ll c=x;c<=(ll)n; ++c )
#define forrr(c,x,n)  for(ll c=x;c>=( ll )n ;--c )
#define db(x) cout << " LOOK " <<(#x) <<" = " <<  x << '\n'
#define ICPC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define printarr(a , l , r ) forr ( i , l , r )cout << a[i] << " ";cout<<endl;
#define printarr2(a, n , m) forr ( i , 1 , n){forr ( j , 1, m )cout << a[i][j] << " ";cout<<endl;}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main()
{
ICPC;
int n ;
cin >> n ;
int a[200007];
set <int  > st;
for ( int i = 0 ; i < n ; i ++ )
{
    cin >> a[i];
    a[i]--;
    if ( i )
        {
            if ( abs(a[i] - a[i-1]) == 1 )
                continue;
            st.insert( abs(a[i] - a[i-1]) );
        }
}

cout << st.size() << endl;
if ( !st.size() )
    cout <<"YES\n"  <<(int)1e9 << " " <<(int) 1e9 ;
else if ( st.size() == 1  )
{
int k = *st.begin() ;
for ( int i = 1 ; i <n  ;i++ )
    if ( abs( a[i] - a[i-1] ) == 1 && a[i] /k != a[i-1] /k  )
        return cout << "NO" , 0 ;

  cout << "YES\n" << (int)1e9 << " " << k << endl;
}
else
 cout << "NO" << endl;

}


#include <bits/stdc++.h>
#define SIZE 1000007
#define MOD 1000000007
#define pi 3.14159265359
using namespace std;

vector<int> pri;
void sieve(){
    bool f[SIZE];
    f[0] = f[1] = 1;
    for(int i=2; i<SIZE; ++i){ if( f[i] ) continue;
        pri.push_back(i);
    for(int j = i*i; i<=10000 && j<SIZE; j += i) f[j] = 1;}}

bool prime(int x) {
if ( x==2)  return true;
if ( x<2 || x%2==0 )  return false;
	for (int i = 3; i *i <= x; i+=2) if (x%i == 0)  return false;  return true; }

vector<int> factor;
void GetFactor(int n){
    for(int i=2; i<=n/i; ++i){
        while( n % i == 0 ){
            factor.push_back(i);
            n /= i;
        }
    }if(n!=1)factor.push_back(n);
}

long long MaxSubarray(long long arr[], int n){
    long long best = -1e18, sum = 0;
    for(int i=0; i<n; ++i){
        sum = max( arr[i], arr[i] + sum );
        best = max( best, sum );
    } return best;
}

long long GCD(long long a, long long b){
    return b ? GCD(b, a%b) : a ;
}
long long LCM(long long a, long long b){
    return a / GCD(a, b) * b;
}

long long fast_power(long long b, long long p){
    long long res=1;
    while(p){
        if(p%2) res = ( res * b ) % MOD;
        b = ( b * b ) % MOD;
        p /= 2;
    }
    return res;
}
bool isvalid ( int r , int c , int R , int C)
{
    return ( r >= 0 && r < R && c >= 0 && c < C);
}
int dx[]= {-1, 1, 0, 0};
int dy[]= {0, 0, 1, -1};
#define ll long long
#define ull unsigned long long
#define lld long long double
#define sz(v)   ((int)((v).size()))
#define sortv(v) sort(v.begin(),v.end());
#define all(v) ((v).begin()), ((v).end())
#define rev(x) reverse(x.begin(),x.end())

#define fr(c,x,n)  for(int c=x;c<n;++c)
#define fz(c,n)  for(int c=0;c< n ;++c)
#define fo(c,n) for(int c = 1; c < n; ++c)
#define fn(c,n) for (int c = n; c>=0; ++c)
#define MNX ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

set < long long  > st;

int main()
{
ll n , a  , x , f = 1 ;
cin>>n;
fz ( i,n )
{
    cin>>x;
    if (!i)
    {
        a = x ;
    }
    else
    {
         if ( abs ( a-x) == 0  )
           continue;
        st.insert(abs(a-x));
        a = x ;
    }
}
if ( f== 0 || st.size() > 2 )
    cout<<"NO";
else if ( st.size() == 2)
{
    if ( *st.begin() != 1 )
        cout<<"NO";
    else
    {
        cout<<"YES\n";
        cout<<1000000000<<" "<<*st.rbegin();
    }

}
else
{
    cout<<"YES\n";
     if ( n== 1)
cout<<1000000000<<" "<<1000000000;
    else
cout<<1000000000<<" "<<*st.begin();
}
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ll long long
#define ld long double
#define vi   vector<int>
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v)  ((int)((v).size()))
#define all(v) ((v).begin()),((v).end())
#define MEM(dp,i) memset(dp ,i, sizeof (dp))
#define repit( cont , i  ) for( auto i : cont)
#define forr(c,x,n)   for(ll c=x;c<=(ll)n; ++c )
#define forrr(c,x,n)  for(ll c=x;c>=( ll )n ;--c )
#define db(x) cout << " LOOK " <<(#x) <<" = " <<  x << '\n'
#define ICPC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define printarr(a , l , r ) forr ( i , l , r )cout << a[i] << " ";cout<<endl;
#define printarr2(a, n , m) forr ( i , 1 , n){forr ( j , 1, m )cout << a[i][j] << " ";cout<<endl;}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int main()
{
ICPC;
int n ;
cin >> n ;
int a[200007];
set <int  > st;
for ( int i = 0 ; i < n ; i ++ )
{
    cin >> a[i];
    a[i]--;
    if ( i )
        {
            if ( abs(a[i] - a[i-1]) == 1 )
                continue;
            st.insert( abs(a[i] - a[i-1]) );
        }
}

if ( !st.size() )
    cout <<"YES\n"  <<(int)1e9 << " " <<(int) 1e9 ;
else if ( st.size() == 1  )
{
int k = *st.begin() ;
for ( int i = 1 ; i <n  ;i++ )
    if ( abs( a[i] - a[i-1] ) == 1 && a[i] /k != a[i-1] /k  )
        return cout << "NO" , 0 ;

  cout << "YES\n" << (int)1e9 << " " << k << endl;
}
else
 cout << "NO" << endl;

}


#include <bits/stdc++.h>
#define SIZE 1000007
#define MOD 1000000007
#define pi 3.14159265359
using namespace std;

vector<int> pri;
void sieve(){
    bool f[SIZE];
    f[0] = f[1] = 1;
    for(int i=2; i<SIZE; ++i){ if( f[i] ) continue;
        pri.push_back(i);
    for(int j = i*i; i<=10000 && j<SIZE; j += i) f[j] = 1;}}

bool prime(int x) {
if ( x==2)  return true;
if ( x<2 || x%2==0 )  return false;
	for (int i = 3; i *i <= x; i+=2) if (x%i == 0)  return false;  return true; }

vector<int> factor;
void GetFactor(int n){
    for(int i=2; i<=n/i; ++i){
        while( n % i == 0 ){
            factor.push_back(i);
            n /= i;
        }
    }if(n!=1)factor.push_back(n);
}

long long MaxSubarray(long long arr[], int n){
    long long best = -1e18, sum = 0;
    for(int i=0; i<n; ++i){
        sum = max( arr[i], arr[i] + sum );
        best = max( best, sum );
    } return best;
}

long long GCD(long long a, long long b){
    return b ? GCD(b, a%b) : a ;
}
long long LCM(long long a, long long b){
    return a / GCD(a, b) * b;
}

long long fast_power(long long b, long long p){
    long long res=1;
    while(p){
        if(p%2) res = ( res * b ) % MOD;
        b = ( b * b ) % MOD;
        p /= 2;
    }
    return res;
}
bool isvalid ( int r , int c , int R , int C)
{
    return ( r >= 0 && r < R && c >= 0 && c < C);
}
int dx[]= {-1, 1, 0, 0};
int dy[]= {0, 0, 1, -1};
#define ll long long
#define ull unsigned long long
#define lld long long double
#define sz(v)   ((int)((v).size()))
#define sortv(v) sort(v.begin(),v.end());
#define all(v) ((v).begin()), ((v).end())
#define rev(x) reverse(x.begin(),x.end())

#define fr(c,x,n)  for(int c=x;c<n;++c)
#define fz(c,n)  for(int c=0;c< n ;++c)
#define fo(c,n) for(int c = 1; c < n; ++c)
#define fn(c,n) for (int c = n; c>=0; ++c)
#define MNX ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

set < long long  > st;

int main()
{
ll n , a  , x , f = 1 ;
cin>>n;
fz ( i,n )
{
    cin>>x;
    if (!i)
    {
        a = x ;
    }
    else
    {
         if ( abs ( a-x) == 0 )
            f = 0 ;

        if ( f )
        {
        st.insert(abs(a-x));
        a = x ;
        }
    }
}
if ( f== 0 || st.size() > 2 )
    cout<<"NO";
else if ( st.size() == 2)
{
    if ( *st.begin() != 1 )
        cout<<"NO";
    else
    {
        cout<<"YES\n";
        cout<<1000000000<<" "<<*st.rbegin();
    }

}
else
{
    cout<<"YES\n";
     if ( n== 1)
cout<<1000000000<<" "<<1000000000;
    else
cout<<1000000000<<" "<<*st.rbegin();
}
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(arr[i] == arr[i+1])
		{
			cout<<"NO";
			return 0;
		}
		if(abs(arr[i+1]-arr[i]) > 1)
		{
			y = abs(arr[i+1]-arr[i]);
			f=0;
		}
		if(f == 0 && (abs(arr[i+1]-arr[i]) != y) && abs(arr[i+1]-arr[i])!=1)
		{
			cout<<"NO";
			return 0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<"YES\n";
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	cout<<(mx)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(arr[i] == arr[i+1])
		{
			cout<<"NO";
			return 0;
		}
		if(abs(arr[i+1]-arr[i]) > 1)
		{
			y = abs(arr[i+1]-arr[i]);
			f=0;
		}
		if(f == 0 && (abs(arr[i+1]-arr[i]) != y) && abs(arr[i+1]-arr[i])!=1)
		{
			cout<<"NO";
			return 0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<"YES\n";
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	cout<<(mx+y+y)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			f=0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<(mx+y+y)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(abs(arr[i+1]-arr[i]) > 1)
		{
			f=0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<"YES\n";
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	cout<<(mx+y+y)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			f=0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	cout<<(mx+y+y)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int arr[200011];
int x,y,mx=-1;

bool check(int x1,int y1,int x2, int y2)
{
	if(x1 != x2 && y1!=y2)
		return false;
	if(x1 == x2 && (abs(y1-y2)!=1))
		return false;
	if(y1 == y2 && (abs(x1-x2)!=1))
		return false;
	return true;
}
int32_t main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	bool f=1;
	mx = arr[0];
	for(int i=0;i<n-1;i++)
	{
		if(abs(arr[i+1]-arr[i]) > 1)
		{
			y = abs(arr[i+1]-arr[i]);
			f=0;
		}
		if(f == 0 && (abs(arr[i+1]-arr[i]) != y) && abs(arr[i+1]-arr[i])!=1)
		{
			cout<<"NO";
			return 0;
		}
		mx = max(arr[i+1],mx);
	}
	if(f)
	{
		cout<<"YES\n";
		cout<<mx<<" "<<1<<"\n";
		return 0;
	}
	for(int i=0;i<n-1;i++)
	{
		if(arr[i+1]-arr[i] > 1)
		{
			y = arr[i+1]-arr[i];
			break;
		}
		else if(arr[i]-arr[i+1]>1)
		{
			y = arr[i]-arr[i+1];
			break;
		}
	}
	//cout<<y<<"\n";
	for(int i=0;i<n-1;i++)
	{
		int x1 = (arr[i]%y == 0 )? ((arr[i]/y)-1):arr[i]/y;
		int y1 = arr[i] - ((x1)*y);

		int x2 = (arr[i+1]%y == 0 )? ((arr[i+1]/y)-1):arr[i+1]/y;
		int y2 = arr[i+1] - ((x2)*y);
		//cout<<i<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<"\n";
		if(!check(x1,y1,x2,y2))
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES\n";
	cout<<(mx+y+y)/y<<" "<<y<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int

int n,m,s,t;
vector<int> graph[1011];
int dist[1011][1011];

void bfs(int node)
{
	queue<int> q;
	bool vis[1011];
	memset(vis,0,sizeof(vis));
	dist[node][node] = 0;

	q.push(node);
	vis[node]=1;
	while(!q.empty())
	{
		int temp = q.front();
		//cout<<temp<<" ";
		q.pop();
		for(int i=0;i<graph[temp].size();i++)
		{
			int child = graph[temp][i];
			if(vis[child])
				continue;
			dist[node][child]=dist[node][temp]+1;
			q.push(child);
			vis[child]=1;
		}
	}
	return;
}

bool c[2001][2001];

int32_t main(){
	cin>>n>>m>>s>>t;
	s--; t--;
	int cnt = 0;
	int x,y;
	memset(c,0,sizeof(c));
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		x--; y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
		c[x][y]=1;
		c[y][x]=1;
		//cout<<"jere";
	}

	for(int i=0;i<n;i++)
	{
		bfs(i);
		//cout<<"here";
	}
	int mn = dist[s][t];

	/*for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			cout<<dist[i][j]<<" ";
		cout<<"\n";
	}*/
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			//cout<<i<<" "<<j<<" "<<dist[s][i]<<" "<<dist[j][t]<<"\n";
			//cout<<c[x][y]<<" ";
			if(c[i][j])
			{
				//cout<<i<<" "<<j<<"\n";
				cnt++;
				continue;
			}
			if(dist[s][i]+1+dist[j][t] < dist[s][t])
			{
				cnt++;
				continue;
			}
			else if(dist[s][j]+1+dist[i][t] < dist[s][t])
			{
				cnt++;
				continue;
			}

			//cout<<"here"<<i<<" "<<j<<"\n";
			//cnt++;
		}
	cout<<(n*(n-1)/2)-cnt<<"\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int
#define INF 9999999

int n,m,s,t;
vector<int> graph[1011];
int dist[1011][1011];

void bfs(int node)
{
	queue<int> q;
	bool vis[1011];
	memset(vis,0,sizeof(vis));
	dist[node][node] = 0;

	q.push(node);
	vis[node]=1;
	while(!q.empty())
	{
		int temp = q.front();
		//cout<<temp<<" ";
		vis[temp]=1;
		q.pop();
		for(int i=0;i<graph[temp].size();i++)
		{
			int child = graph[temp][i];
			if(vis[child])
				continue;
			dist[node][child]=min(dist[node][child],dist[node][temp]+1);
			q.push(child);
			vis[child]=1;
		}
	}
	return;
}

bool c[2001][2001];

int32_t main(){
	cin>>n>>m>>s>>t;
	s--; t--;
	int cnt = 0;
	int x,y;
	memset(c,0,sizeof(c));
	memset(dist,INF,sizeof(dist));
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		x--; y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
		c[x][y]=1;
		c[y][x]=1;
		//cout<<"jere";
	}

	for(int i=0;i<n;i++)
	{
		bfs(i);
		//cout<<"here";
	}
	int mn = dist[s][t];

	/*for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			cout<<dist[i][j]<<" ";
		cout<<"\n";
	}*/
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			//cout<<i<<" "<<j<<" "<<dist[s][i]<<" "<<dist[j][t]<<"\n";
			//cout<<c[x][y]<<" ";
			if(c[i][j] || i==j)
			{
				//cout<<i<<" "<<j<<"\n";
				cnt++;
				continue;
			}
			if(dist[s][i]+1+dist[j][t] < mn)
			{
				cnt++;
				continue;
			}
			else if(dist[s][j]+1+dist[i][t] < mn)
			{
				cnt++;
				continue;
			}

			//cout<<"here"<<i<<" "<<j<<"\n";
			//cnt++;
		}
	cout<<(n*(n))-cnt<<"\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long double ld;
#define N 200005
ll inf=1e5;
ll mod=1e9+7;
ll arr[N];
vector<ll> arr2[N];
// Driver program to test above
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,m,p;
    cin>>n>>m>>p;
    ll max1=-1;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        arr2[((i-1)%p)+1].push_back(x);
        max1=max(max1,(i-1)%p+1);

    }
    map<ll,ll> par2;
    for(ll i=1;i<=m;i++)
    {
        cin>>arr[i];
        par2[arr[i]]++;

    }
    vector<ll> res2;
    ll res=0;
    for(ll i=1;i<=max1;i++)
    {
        map<ll,ll> par;

        if(arr2[i].size()<m)
            continue;

        ll matched=0;
        for(ll j=0;j<m;j++)
        {
            if((par[arr2[i][j]]==par2[arr2[i][j]]) && (par2[arr2[i][j]]!=0) )
                matched--;

            par[arr2[i][j]]++;
            if(par[arr2[i][j]]==par2[arr2[i][j]])
                matched++;

        }
        if(matched==par2.size())
        {
            res++;
            res2.push_back(i+(m-1)*p);
        }

        for(ll j=m;j<arr2[i].size();j++)
        {
            if(arr2[i][j]!=arr2[i][j-m])
            {
                if((par[arr2[i][j]]==par2[arr2[i][j]]) && (par2[arr2[i][j]]!=0) )
                matched--;

                par[arr2[i][j]]++;

                if((par[arr2[i][j]]==par2[arr2[i][j]]) && (par2[arr2[i][j]]!=0) )
                    matched++;

                if((par[arr2[i][j-m]]==par2[arr2[i][j-m]]) && (par2[arr2[i][j-m]]!=0) )
                matched--;

                par[arr2[i][j-m]]--;

                if((par[arr2[i][j-m]]==par2[arr2[i][j-m]]) && (par2[arr2[i][j-m]]!=0) )
                    matched++;

                if(matched==par2.size())
                {
                    res++;
                    res2.push_back(i+j*p);
                }

            }

        }

    }

    cout<<res<<endl;
    sort(res2.begin(),res2.end());
    for(ll x:res2)
        cout<<x-(m-1)*p<<" ";

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
typedef long long ll;
const int maxinput=200005;
int n,m,p;
int a[maxinput];
unordered_map <int,int> b;
int nummatches=0;
void add(int pos,unordered_map <int,int> &currentmap)
{
    if(b.find(a[pos])!=b.end())
    {
        if(currentmap.find(a[pos])==currentmap.end())
            currentmap[a[pos]]=0;
        currentmap[a[pos]]++;
        if(currentmap[a[pos]]<=b[a[pos]])
            nummatches++;
    }
}
void remove(int pos,unordered_map <int,int> &currentmap)
{
    if(currentmap.find(a[pos])!=currentmap.end())
    {
        currentmap[a[pos]]--;
        if(currentmap[a[pos]]<b[a[pos]])
            nummatches--;
    }
}
int main()
{
    FAST
    cin>>n>>m>>p;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
    {
        int temp;
        cin>>temp;
        if(b.find(temp)==b.end())
            b[temp]=0;
        b[temp]++;
    }

    vector <int> ans;
    for(int i=1;i<=p;i++)
    {
        unordered_map <int,int> currentmap;
        nummatches=0;
        for(int j=i;j<=min(i+(m-1)*p,n);j+=p)
            add(j,currentmap);
        if(nummatches==m)
            ans.push_back(i);
        int currentstart,currentlast;
        currentstart=i;currentlast=i+(m-1)*p;
        while(currentlast<=n)
        {
            remove(currentstart,currentmap);
            currentstart+=p;
            currentlast+=p;
            if(currentlast<=n)
            {
                add(currentlast,currentmap);
                if(nummatches==m)
                    ans.push_back(currentstart);
            }
        }
    }

    sort(ans.begin(),ans.end());
    cout<<ans.size()<<"\n";
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<" ";
    cout<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
typedef long long ll;
const ll maxinput=200005;
ll n,m,p;
ll a[maxinput];
unordered_map <ll,ll> b;
ll nummatches=0;
void add(ll pos,unordered_map <ll,ll> &currentmap)
{
    if(b.find(a[pos])!=b.end())
    {
        if(currentmap.find(a[pos])==currentmap.end())
            currentmap[a[pos]]=0;
        currentmap[a[pos]]++;
        if(currentmap[a[pos]]<=b[a[pos]])
            nummatches++;
    }
}
void remove(ll pos,unordered_map <ll,ll> &currentmap)
{
    if(currentmap.find(a[pos])!=currentmap.end())
    {
        currentmap[a[pos]]--;
        if(currentmap[a[pos]]<b[a[pos]])
            nummatches--;
    }
}
int main()
{
    FAST
    cin>>n>>m>>p;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    for(ll i=0;i<m;i++)
    {
        ll temp;
        cin>>temp;
        if(b.find(temp)==b.end())
            b[temp]=0;
        b[temp]++;
    }

    vector <ll> ans;
    for(ll i=1;i<=p;i++)
    {
        unordered_map <ll,ll> currentmap;
        nummatches=0;
        for(ll j=i;j<=min(i+(m-1)*p,n);j+=p)
            add(j,currentmap);
        if(nummatches==m)
            ans.push_back(i);
        ll currentstart,currentlast;
        currentstart=i;currentlast=i+(m-1)*p;
        while(currentlast<=n)
        {
            remove(currentstart,currentmap);
            currentstart+=p;
            currentlast+=p;
            if(currentlast<=n)
            {
                add(currentlast,currentmap);
                if(nummatches==m)
                    ans.push_back(currentstart);
            }
        }
    }

    sort(ans.begin(),ans.end());
    cout<<ans.size()<<"\n";
    for(ll i=0;i<ans.size();i++)
        cout<<ans[i]<<" ";
    cout<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
typedef long long ll;
const int maxinput=100005;
int n,m,p;
int a[maxinput];
unordered_map <int,int> b;
int nummatches=0;
void add(int pos,unordered_map <int,int> &currentmap)
{
    if(b.find(a[pos])!=b.end())
    {
        if(currentmap.find(a[pos])==currentmap.end())
            currentmap[a[pos]]=0;
        currentmap[a[pos]]++;
        if(currentmap[a[pos]]<=b[a[pos]])
            nummatches++;
    }
}
void remove(int pos,unordered_map <int,int> &currentmap)
{
    if(currentmap.find(a[pos])!=currentmap.end())
    {
        currentmap[a[pos]]--;
        if(currentmap[a[pos]]<b[a[pos]])
            nummatches--;
    }
}
int main()
{
    FAST
    cin>>n>>m>>p;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
    {
        int temp;
        cin>>temp;
        if(b.find(temp)==b.end())
            b[temp]=0;
        b[temp]++;
    }

    vector <int> ans;
    for(int i=1;i<=p;i++)
    {
        unordered_map <int,int> currentmap;
        nummatches=0;
        for(int j=i;j<=min(i+(m-1)*p,n);j+=p)
            add(j,currentmap);
        if(nummatches==m)
            ans.push_back(i);
        int currentstart,currentlast;
        currentstart=i;currentlast=i+(m-1)*p;
        while(currentlast<=n)
        {
            remove(currentstart,currentmap);
            currentstart+=p;
            currentlast+=p;
            if(currentlast<=n)
            {
                add(currentlast,currentmap);
                if(nummatches==m)
                    ans.push_back(currentstart);
            }
        }
    }

    sort(ans.begin(),ans.end());
    cout<<ans.size()<<"\n";
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<" ";
    cout<<"\n";
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 1e5 + 5;
deque<int> slide[N];
map<int , int> counter[N] , orig;
int n , m , p , a[N] , b[N] , all[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] == orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 2e5 + 5;
map<int , int> orig;
ll n , m , p , a[N] , b[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    ll q = n - (m - 1) * p + 1;
    if(q < 0) return cout << 0 , 0;

    int all[min(q , p)] = {};
    map<int , int> counter[min(q , p)];
    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] == orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 2e5 + 5;
deque<int> slide[N];
map<int , int> counter[N] , orig;
int n , m , p , a[N] , b[N] , all[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] == orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 1e5 + 5;
deque<int> slide[N];
map<int , int> counter[N] , orig;
int n , m , p , a[N] , b[N] , all[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] - 1 < orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 2e5 + 5;
map<int , int> orig;
ll n , m , p , a[N] , b[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    ll q = n - (m - 1) * p + 1;
    if(q <= 0) return cout << 0 , 0;

    int all[min(q , p)] = {};
    map<int , int> counter[min(q , p)];
    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] == orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 1e5 + 5;
deque<int> slide[N];
map<int , int> counter[N] , orig;
int n , m , p , a[N] , b[N] , all[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[b[i % m]])
            all[i % p]++;
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = i + (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] - 1 < orig[a[i % m]])
            all[i % p]--;
        counter[i % p][a[i]]--;

        if(counter[ r % p][a[r]] + 1 == orig[a[r]])
            all[ r % p ]++;
        counter[ r % p ][a[r]]++;

        if(all[ r % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
typedef vector<vector<ll>> mat;

const int N = 2e5 + 5;
map<int , int> orig;
int n , m , p , a[N] , b[N];
vector<int> out;

int main()
{
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

    cin >> n >> m >> p;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i];
    for(int j = 0 ; j < m ; j++)
        cin >> b[j] , orig[b[j]]++;

    int all[N] = {};
    map<int , int> counter[min(n - (m - 1) * p , p)];
    for(int i = 0 ; i <= (m - 1) * p ; i++)
    {
        if(counter[i % p][a[i]] + 1 == orig[a[i]])
            all[i % p] += orig[a[i]];
        counter[i % p][a[i]]++;
    }

    if(all[0] == m) out.push_back(0);

    for(int i = 0 , r = (m - 1) * p + 1 ; r < n ; r++ , i++)
    {
        if(counter[i % p][a[i]] == orig[a[i]])
            all[i % p] -= orig[a[i]];
        counter[i % p][a[i]]--;

        if(counter[ r % p ][a[r]] + 1 == orig[a[r]])
            all[ r % p ] += orig[a[r]];
        counter[ r % p ][a[r]]++;

        if(all[ (i + 1) % p ] == m) out.push_back(i + 1);
    }

    cout << out.size() << '\n';
    for(auto i : out)
        cout << i + 1 << " ";

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//data structure (fenwick substitute)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define ull uint64_t
#define ll int64_t

//debugging snippets
#define Local freopen("input","r",stdin)
#define tr1(x)                cerr << #x << ": " << x << endl;
#define tr2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define tr3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define tr4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int a[200001];
int b[200001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, p;
    cin >> n >> m >> p;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    vector<int> ans;
    for (int i = 1; i <= p && i + (m - 1) * p <= n; ++i) {
        map<int, int> st;
        for (int j = 1; j <= m; ++j) {
            st[b[j]]++;
        }
        int extra = 0;
        int cnt = m;
        for (int j = i; j <= n; j += p) {
            if (st[a[j]] > 0) {
                cnt--;
            } else extra++;
            st[a[j]]--;
            if (cnt == 0) {
                ans.pb(j - (m - 1) * p);
            }
            if (j >= i + (m - 1) * p) {
                st[a[j - (m - 1) * p]]++;
                if (st[a[j - (m - 1) * p]] <= 0) extra--;
                else cnt++;
            }
        }
    }
    cout << ans.size() << '\n';
    for (auto i : ans) {
        cout << i << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//data structure (fenwick substitute)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define ull uint64_t
#define ll int64_t

//debugging snippets
#define Local freopen("input","r",stdin)
#define tr1(x)                cerr << #x << ": " << x << endl;
#define tr2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define tr3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define tr4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int a[200001];
int b[200001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, p;
    cin >> n >> m >> p;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    vector<int> ans;
    for (int i = 1; i <= p && i + (m - 1) * p <= n; ++i) {
        map<int, int> st;
        for (int j = 1; j <= m; ++j) {
            st[b[j]]++;
        }
        int extra = 0;
        int cnt = m;
        for (int j = i; j <= n; j += p) {
            if (st[a[j]] > 0) {
                cnt--;
            } else extra++;
            st[a[j]]--;
            if (cnt == 0) {
                ans.pb(j - (m - 1) * p);
            }
            if (j >= i + (m - 1) * p) {
                st[a[j - (m - 1) * p]]++;
                if (st[a[j - (m - 1) * p]] <= 0) extra--;
                else cnt++;
            }
        }
    }
    cout << ans.size() << '\n';
    sort(ans.begin(), ans.end());
    for (auto i : ans) {
        cout << i << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//data structure (fenwick substitute)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define ull uint64_t
#define ll int64_t

//debugging snippets
#define Local freopen("input","r",stdin)
#define tr1(x)                cerr << #x << ": " << x << endl;
#define tr2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define tr3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define tr4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int a[200001];
int b[200001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, p;
    cin >> n >> m >> p;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    vector<int> ans;
    for (int i = 1; i <= p && i + ll(m - 1) * p <= n; ++i) {
        map<int, int> st;
        for (int j = 1; j <= m; ++j) {
            st[b[j]]++;
        }
        int extra = 0;
        int cnt = m;
        for (int j = i; j <= n; j += p) {
            if (st[a[j]] > 0) {
                cnt--;
            } else extra++;
            st[a[j]]--;
            if (cnt == 0) {
                ans.pb(j - (m - 1) * p);
            }
            if (j >= i + (m - 1) * p) {
                st[a[j - (m - 1) * p]]++;
                if (st[a[j - (m - 1) * p]] <= 0) extra--;
                else cnt++;
            }
        }
    }
    cout << ans.size() << '\n';
    sort(ans.begin(), ans.end());
    for (auto i : ans) {
        cout << i << " ";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++)
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const int mod = 1e9 + 7;
int Mod(int x){x%=mod;if(x<0)x+=mod;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()
#define db double

int__ main() {
	fast;

	int n,m,p; cin >> n >> m >> p;

	vvi a(p);

	for(int i=0;i<n;i++) {
		int x; cin >> x; a[i%p].pb(x);
	}

	map<int,int> c;
	for(int i=0;i<m;i++) {
		int x; cin >> x; c[x]++;
	}

	// watch(a);

	vi ans;
	for(int i=0;i<p;i++) {
		if(a[i].size() < m) continue;
		map<int,int> t=c;

		int l=0,r=m-1;
		for(int x=l;x<=r;x++) {
			if(t[a[i][x]] == 1) {
				t.erase(a[i][x]);
			} else t[a[i][x]]--;
		}
		while(r < a[i].size()) {
			// for(auto x:t) {
			// 	cout << x << endl;
			// } cout << "---------" << endl;
			if(t.size() == 0) {
				ans.pb(i + p*l);
			}
			t[a[i][l]]++; if(t[a[i][l]] == 0) t.erase(a[i][l]);
			l++;
			r++;
			if(r == a[i].size()) break;
			if(t[a[i][r]] == 1) {
				t.erase(a[i][r]);
			} else t[a[i][r]]--;
		}
	}

	cout << ans.size() << endl;
	sort(all(ans));
	for(int x:ans) cout << x+1 << " ";
}


#include <bits/stdc++.h>
using namespace std;
typedef int int__;
#define int long long
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
#define vi vector<int>
#define vvi vector<vi>
#define fi first
#define se second
#define forn(i, n)for(int i=0;i<int__(n);i++)
#define sz(a)int__(a.size())
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a){return out << "(" << a.first << ", " << a.second << ")";}
template<class A>ostream& operator<<(ostream& out,const vector<A>&v){out<<"[";forn(i,sz(v)){if(i)out<<", ";out<<v[i];}return out<<"]";}
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
const int mod = 1e9 + 7;
int Mod(int x){x%=mod;if(x<0)x+=mod;return x;}
int Pow(int x,int n){if(n==0)return 1;int t=Pow(x,n/2);t=Mod(t*t);if(n&1)t=Mod(t*x);return t;}
#define watch(x) cout << #x << " : " << x << endl;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
#define all(x) x.begin(), x.end()
#define db double

int__ main() {
	fast;

	int n,m,p; cin >> n >> m >> p;

	vvi a(p);

	for(int i=0;i<n;i++) {
		int x; cin >> x; a[i%p].pb(x);
	}

	map<int,int> c;
	for(int i=0;i<m;i++) {
		int x; cin >> x; c[x]++;
	}

	// watch(a);

	vi ans;
	for(int i=0;i<p;i++) {
		if(a[i].size() < m) continue;
		map<int,int> t=c;

		int l=0,r=m-1;
		for(int x=l;x<=r;x++) {
			if(t[a[i][x]] == 1) {
				t.erase(a[i][x]);
			} else t[a[i][x]]--;
		}
		while(r < a[i].size()) {
			// for(auto x:t) {
			// 	cout << x << endl;
			// } cout << "---------" << endl;
			if(t.size() == 0) {
				ans.pb(i + p*l);
			}
			t[a[i][l]]++; if(t[a[i][l]] == 0) t.erase(a[i][l]);
			l++;
			r++;
			if(r == a[i].size()) break;
			if(t[a[i][r]] == 1) {
				t.erase(a[i][r]);
			} else t[a[i][r]]--;
		}
	}

	cout << ans.size() << endl;
	for(int x:ans) cout << x+1 << " ";
}


/*
ID: temurxo1
PROG: fence
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <bitset>
#include <stdio.h>
#include <vector>
#include <list>
using namespace std;

#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define Coder 404
typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPI;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
const int inf = 1000000404;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000404ll;
const ld EPS = 1e-9;
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); }
template <typename t1, typename t2> inline void upmin(t1 &a, t2 b) { a = min(a, (t1)b); }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }
inline bool pal(string &x) { int n = (int)x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0,-1, 0 };
int dy[] = { 0, 1, 0,-1 };
int dx8[] = { 1, 1, 1, 0, 0,-1,-1,-1 };
int dy8[] = { -1, 0, 1, 1,-1,-1, 0, 1 };
int SQ = 400;

#define debug 1
#define N 223456
int a[N];
int b[N];
void solve()
{
	map<int, int> mm,etalon;
	int n, m, p;
	cin >> n >> m >> p;
	REP(i, 1, n + 1) scanf("%d", a + i);
	REP(i, 1, m + 1) {
		scanf("%d", b + i);
		etalon[b[i]]++;
	}
	VI ans;
	REP(k, 1, p + 1) {
		for (int i = k; i <= n; i += p) {
			int foo = i - m*p;
			if (foo >= 1) {
				foo = a[foo];
				mm[foo]--;
				if (!mm[foo]) mm.erase(foo);
			}
			mm[a[i]]++;
		//	for (auto x : mm) cout << x.first << ' ' << x.second << endl; cout << endl;
			if (mm == etalon) ans.push_back(i-(m-1)*p);
		}
		mm.clear();
	}
	sort(ALL(ans));
	cout << SZ(ans)<< endl;
	for (auto x : ans) cout << x << ' ';
}

int main()
{
	//freopen("fence.in", "r", stdin);
	//freopen("fence.out", "w", stdout);
	//ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;

	//cin>>t;

	while (t--) {
		solve();
	};

	getchar();
	getchar();
	return 0;
}


/*
ID: temurxo1
PROG: fence
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <bitset>
#include <stdio.h>
#include <vector>
#include <list>
using namespace std;

#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define Coder 404
typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPI;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
const int inf = 1000000404;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000404ll;
const ld EPS = 1e-9;
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); }
template <typename t1, typename t2> inline void upmin(t1 &a, t2 b) { a = min(a, (t1)b); }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }
inline bool pal(string &x) { int n = (int)x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0,-1, 0 };
int dy[] = { 0, 1, 0,-1 };
int dx8[] = { 1, 1, 1, 0, 0,-1,-1,-1 };
int dy8[] = { -1, 0, 1, 1,-1,-1, 0, 1 };
int SQ = 400;

#define debug 1
#define N 223456
int a[N];
int b[N];
void solve()
{
	map<int, int> mm,etalon;
	int n, m, p;
	cin >> n >> m >> p;
	REP(i, 1, n + 1) scanf("%d", a + i);
	REP(i, 1, m + 1) {
		scanf("%d", b + i);
		etalon[b[i]]++;
	}
	VI ans;
	REP(k, 1, p + 1) {
		for (int i = k; i <= n; i += p) {
			int foo = i - m*p;
			if (foo >= 1) {
				foo = a[foo];
				mm[foo]--;
				if (!mm[foo]) mm.erase(foo);
			}
			mm[a[i]]++;
		//	for (auto x : mm) cout << x.first << ' ' << x.second << endl; cout << endl;
			if (mm == etalon) ans.push_back(i-(m-1)*p);
		}
		mm.clear();
	}
	cout << SZ(ans)<< endl;
	for (auto x : ans) cout << x << ' ';
}

int main()
{
	//freopen("fence.in", "r", stdin);
	//freopen("fence.out", "w", stdout);
	//ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;

	//cin>>t;

	while (t--) {
		solve();
	};

	getchar();
	getchar();
	return 0;
}


/*
ID: temurxo1
PROG: fence
LANG: C++11
*/
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <math.h>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <string.h>
#include <cstring>
#include <queue>
#include <iomanip>
#include <istream>
#include <map>
#include <stack>
#include <numeric>
#include <ostream>
#include <set>
#include <cassert>
#include <sstream>
#include <string>
#include <utility>
#include <bitset>
#include <stdio.h>
#include <vector>
#include <list>
using namespace std;

#define dout if (debug) cout
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define Coder 404
typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPI;
#define REP(i,a,n) for (int i=a;i<n;i++)
#define PER(i,a,n) for (int i=n-1;i>=a;i--)
const int inf = 1000000404;
const ll MOD = 1000000007ll;
const ld PI = acos(-1.0);
const ll INF = 2000000000000000404ll;
const ld EPS = 1e-9;
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename t1, typename t2> inline void upmax(t1 &a, t2 b) { a = max(a, (t1)b); }
template <typename t1, typename t2> inline void upmin(t1 &a, t2 b) { a = min(a, (t1)b); }
template <typename T>inline T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template <typename T>inline T lcm(T a, T b) { return a*(b / gcd(a, b)); }
template <typename T>inline T sqr(T a) { return a*a; }
inline bool pal(string &x) { int n = (int)x.length(); REP(i, 0, n / 2) { if (x[i] != x[n - i - 1]) return 0; }return 1; }
int month[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int dx[] = { 1, 0,-1, 0 };
int dy[] = { 0, 1, 0,-1 };
int dx8[] = { 1, 1, 1, 0, 0,-1,-1,-1 };
int dy8[] = { -1, 0, 1, 1,-1,-1, 0, 1 };
int SQ = 400;

#define debug 1
#define N 223456
int a[N];
int b[N];
void solve()
{
	map<int, int> mm,etalon;
	int n, m, p;
	cin >> n >> m >> p;
	REP(i, 1, n + 1) scanf("%d", a + i);
	REP(i, 1, m + 1) {
		scanf("%d", b + i);
		etalon[b[i]]++;
	}
	VI ans;
	REP(k, 1, p + 1) {
		for (int i = k; i <= n; i += p) {
			ll foo = (ll)i - (ll)m*p;
			if (foo >= 1) {
				foo = a[foo];
				mm[foo]--;
				if (!mm[foo]) mm.erase(foo);
			}
			mm[a[i]]++;
		//	for (auto x : mm) cout << x.first << ' ' << x.second << endl; cout << endl;
			if (mm == etalon) ans.push_back(i-(m-1)*p);
		}
		mm.clear();
	}
	sort(ALL(ans));
	cout << SZ(ans)<< endl;
	for (auto x : ans) cout << x << ' ';
}

int main()
{
	//freopen("fence.in", "r", stdin);
	//freopen("fence.out", "w", stdout);
	//ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	int t = 1;

	//cin>>t;

	while (t--) {
		solve();
	};

	getchar();
	getchar();
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const double pi = acos(-1);
const int N = 5e5 + 5, OO = 1e9;

int n, m, p, a[N], b[N], d, f[N];
map<int, int> M;
vector<int> ans;

int main()
{
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<n; i++){
        scanf("%d", a + i);
        if(!M.count(a[i]))
            M[a[i]] = d++;
        a[i] = M[a[i]];
    }
    for(int i=0; i<m; i++){
        scanf("%d", b + i);
        if(!M.count(b[i]))
            M[b[i]] = d++;
        b[i] = M[b[i]];
        ++f[b[i]];
    }
    for(int st=0; st<p && st + (m - 1) * p < n; st++){
        int l = st, r = st + (m - 1) * p, cnt = 0;
        for(int i=0; i<m; i++){
            cnt += f[a[i * p + st]] > 0;
            --f[a[i * p + st]];
        }
        if(cnt == m)
            ans.push_back(st);
        while(r + p < n){
            r += p;
            cnt += f[a[r]] > 0;
            --f[a[r]];
            cnt -= f[a[l]] >= 0;
            ++f[a[l]];
            l += p;
            if(cnt == m)
                ans.push_back(l);
        }
        for(; l <= r; l += p)
            ++f[a[l]];
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans)
        printf("%d ", i + 1);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const double pi = acos(-1);
const int N = 5e5 + 5, OO = 1e9;

int n, m, p, a[N], b[N], d, f[N];
map<int, int> M;
vector<int> ans;

int main()
{
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<n; i++){
        scanf("%d", a + i);
        if(!M.count(a[i]))
            M[a[i]] = d++;
        a[i] = M[a[i]];
    }
    for(int i=0; i<m; i++){
        scanf("%d", b + i);
        if(!M.count(b[i]))
            M[b[i]] = d++;
        b[i] = M[b[i]];
        ++f[b[i]];
    }
    for(int st=0; st<p && st + (m - 1ll) * p < n; st++){
        int l = st, r = st + (m - 1) * p, cnt = 0;
        for(int i=0; i<m; i++){
            cnt += f[a[i * p + st]] > 0;
            --f[a[i * p + st]];
        }
        if(cnt == m)
            ans.push_back(st);
        while(r + p < n){
            r += p;
            cnt += f[a[r]] > 0;
            --f[a[r]];
            cnt -= f[a[l]] >= 0;
            ++f[a[l]];
            l += p;
            if(cnt == m)
                ans.push_back(l);
        }
        for(; l <= r; l += p)
            ++f[a[l]];
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans)
        printf("%d ", i + 1);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const double pi = acos(-1);
const int N = 4e5 + 5, OO = 1e9;

int n, m, p, a[N], b[N], d, f[N];
map<int, int> M;
vector<int> ans;

int main()
{
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<n; i++){
        scanf("%d", a + i);
        if(!M.count(a[i]))
            M[a[i]] = d++;
        a[i] = M[a[i]];
    }
    for(int i=0; i<m; i++){
        scanf("%d", b + i);
        if(!M.count(b[i]))
            M[b[i]] = d++;
        b[i] = M[b[i]];
        ++f[b[i]];
    }
    for(int st=0; st<p && st + (m - 1) * p < n; st++){
        int l = st, r = st + (m - 1) * p, cnt = 0;
        for(int i=0; i<m; i++){
            cnt += f[a[i * p + st]] > 0;
            --f[a[i * p + st]];
        }
        if(cnt == m)
            ans.push_back(st);
        while(r + p < n){
            r += p;
            cnt += f[a[r]] > 0;
            --f[a[r]];
            cnt -= f[a[l]] >= 0;
            ++f[a[l]];
            l += p;
            if(cnt == m)
                ans.push_back(l);
        }
        for(; l <= r; l += p)
            ++f[a[l]];
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans)
        printf("%d ", i + 1);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const double pi = acos(-1);
const int N = 2e5 + 5, OO = 1e9;

int n, m, p, a[N], b[N], d, f[N];
map<int, int> M;
vector<int> ans;

int main()
{
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<n; i++){
        scanf("%d", a + i);
        if(!M.count(a[i]))
            M[a[i]] = d++;
        a[i] = M[a[i]];
    }
    for(int i=0; i<m; i++){
        scanf("%d", b + i);
        if(!M.count(b[i]))
            M[b[i]] = d++;
        b[i] = M[b[i]];
        ++f[b[i]];
    }
    for(int st=0; st<p && st + (m - 1) * p < n; st++){
        int l = st, r = st + (m - 1) * p, cnt = 0;
        for(int i=0; i<m; i++){
            cnt += f[a[i * p + st]] > 0;
            --f[a[i * p + st]];
        }
        if(cnt == m)
            ans.push_back(st);
        while(r + p < n){
            r += p;
            cnt += f[a[r]] > 0;
            --f[a[r]];
            cnt -= f[a[l]] >= 0;
            ++f[a[l]];
            l += p;
            if(cnt == m)
                ans.push_back(l);
        }
        for(; l <= r; l += p)
            ++f[a[l]];
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans)
        printf("%d ", i + 1);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

const double pi = acos(-1);
const int N = 2e5 + 5, OO = 1e9;

int n, m, p, a[N], b[N], d, f[N];
map<int, int> M;
vector<int> ans;

int main()
{
    scanf("%d %d %d", &n, &m, &p);
    for(int i=0; i<n; i++){
        scanf("%d", a + i);
        if(!M.count(a[i]))
            M[a[i]] = d++;
        a[i] = M[a[i]];
    }
    for(int i=0; i<m; i++){
        scanf("%d", b + i);
        if(!M.count(b[i]))
            M[b[i]] = d++;
        b[i] = M[b[i]];
        ++f[b[i]];
    }
    for(int st=0; st<p && st + (m - 1) * p < n; st++){
        int l = st, r = st + (m - 1) * p, cnt = 0;
        for(int i=0; i<m; i++){
            cnt -= !f[a[i * p + st]];
            --f[a[i * p + st]];
            cnt += !f[a[i * p + st]];
        }
        if(cnt == m)
            ans.push_back(st);
        while(r + p < n){
            r += p;
            cnt -= !f[a[r]];
            --f[a[r]];
            cnt += !f[a[r]];
            cnt -= !f[a[l]];
            ++f[a[l]];
            cnt += !f[a[l]];
            l += p;
            if(cnt == m)
                ans.push_back(l);
        }
        for(; l <= r; l += p)
            ++f[a[l]];
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans)
        printf("%d ", i + 1);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;

map<int,int> g, f[MAX];
int a[MAX], cnt[MAX];

int main() {
    //fr;fw;
    int n, m, p;
    cin >> n >> m >> p;
    REP(i,n) cin >> a[i];

    REP(i,m){
      int x;
      cin >> x;
      g[x]++;
    }

    vector<int> ret;
    for(int i=0;i<n;i++){
      f[i%p][a[i]]++;
      cnt[i%p]++;
      if(cnt[i%p] > m){
        cnt[i%p]--;
        f[i%p][a[i-m*p]]--;
        if(f[i%p][a[i-m*p]] == 0) f[i%p].erase(a[i-m*p]);
      }
      if(cnt[i%p] == m && f[i%p] == g){
        ret.pb(i-(m-1)*p);
      }
    }
    sort(ret.begin(), ret.end());
    cout << ret.size() << "\n";
    REP(i,ret.size()) cout << ret[i]+1 << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;

map<int,int> g, f[MAX];
int a[MAX], cnt[MAX];

int main() {
    //fr;fw;
    int n, m, p;
    cin >> n >> m >> p;
    REP(i,n) cin >> a[i];

    REP(i,m){
      int x;
      cin >> x;
      g[x]++;
    }

    vector<int> ret;
    for(int i=0;i<n;i++){
      f[i%p][a[i]]++;
      cnt[i%p]++;
      if(cnt[i%p] > m){
        cnt[i%p]--;
        f[i%p][a[i-m*p]]--;
        if(f[i%p][a[i-m*p]] == 0) f[i%p].erase(a[i-m*p]);
      }
      if(cnt[i%p] == m && f[i%p] == g){
        ret.pb(i-(m-1)*p);
      }
    }
    sort(ret.begin(), ret.end());
    cout << ret.size() << "\n";
    REP(i,ret.size()) cout << ret[i]+1 << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;

int a[MAX], cnt[MAX], f[MAX];

int hashit(int b) {
  return b * b * b + 453 * b + b * (32423 ^ b) * (32454 ^ (b * b));
}

 main() {
    //fr;fw;
    int n, m, p;
    cin >> n >> m >> p;
    REP(i,n) {
      cin >> a[i];
      a[i] = hashit(a[i]);
    }

    int g = 0;
    REP(i,m){
      int x;
      cin >> x;
      g += hashit(x);
    }

    vector<int> ret;

    for(int i=0;i<n;i++){
      f[i%p] += a[i];
      cnt[i%p]++;

      if(cnt[i%p] > m){
        cnt[i%p]--;
        f[i%p] -= a[i-m*p];
      }

      if(cnt[i%p] == m && f[i%p] == g){
        ret.pb(i-(m-1)*p);
      }
    }
    sort(ret.begin(), ret.end());
    cout << ret.size() << "\n";
    REP(i,ret.size()) cout << ret[i]+1 << " ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,p,m,k,oks,sz,ans,h;
long long a[400007];
long long b[400007];
bool li;
map<long long,int> mm;
vector<int> v[400007];
int br[800007];
set<int> s;
set<int> id;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>p;
    k=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(mm[a[i]]==0){
            mm[a[i]]=k;
            k++;
        }
        v[i%p].push_back(mm[a[i]]);
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(mm[b[i]]==0){
            mm[b[i]]=k;
            k++;
        }
        b[i]=mm[b[i]];
        br[b[i]]++;
        s.insert(b[i]);
    }
    h=s.size();
    for(int i=0;i<p;i++){
        oks=h;
        for(int f=0;f<v[i].size();f++){
            br[v[i][f]]--;
            if(br[v[i][f]]==0)oks--;
            else if(br[v[i][f]]==-1)oks++;
            if(f-m>=0){
                br[v[i][f-m]]++;
                if(br[v[i][f-m]]==0)oks--;
                else if(br[v[i][f-m]]==1)oks++;
            }
            if(oks==0 and f+1>=m){
                id.insert(p*f+i+1);
                ans++;
            }
        }
        for(int f=v[i].size()-m;f<v[i].size();f++){
            br[v[i][f]]++;
        }
    }
    cout<<ans<<"\n";
    for(int i:id){
        if(li)cout<<" ";
        cout<<i-m*p+1*p;
        li=true;
    }
    cout<<"\n";
    return 0;
}
/// STFU codeforces says that I have 100 ///


#include<bits/stdc++.h>
using namespace std;
int n,p,m,k,oks,sz,ans,h;
long long a[400007];
long long b[400007];
bool li;
unordered_map<long long,int> mm;
vector<int> v[400007];
int br[800007];
unordered_set<int> s;
vector<int> id;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>p;
    k=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(mm[a[i]]==0){
            mm[a[i]]=k;
            k++;
        }
        v[i%p].push_back(mm[a[i]]);
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(mm[b[i]]==0){
            mm[b[i]]=k;
            k++;
        }
        b[i]=mm[b[i]];
        br[b[i]]++;
        s.insert(b[i]);
    }
    h=s.size();
    for(int i=0;i<p;i++){
        oks=h;
        for(int f=0;f<v[i].size();f++){
            br[v[i][f]]--;
            if(br[v[i][f]]==0)oks--;
            else if(br[v[i][f]]==-1)oks++;
            if(f-m>=0){
                br[v[i][f-m]]++;
                if(br[v[i][f-m]]==0)oks--;
                else if(br[v[i][f-m]]==1)oks++;
            }
            if(oks==0 and f+1>=m){
                id.push_back(p*f+i+1);
                ans++;
            }
        }
        for(int f=v[i].size()-m;f<v[i].size();f++){
            br[v[i][f]]++;
        }
    }
    cout<<ans<<"\n";
    sort(id.begin(),id.end());
    for(int i=0;i<id.size();i++){
        cout<<id[i]-p*m+p<<" ";
    }
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,p,m,k,oks,sz,ans,h;
long long a[200007];
long long b[200007];
map<long long,int> mm;
vector<int> v[200007];
int br[400007];
set<int> s;
set<int> id;
int main(){
    cin>>n>>m>>p;
    k=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(mm[a[i]]==0){
            mm[a[i]]=k;
            k++;
        }
        v[i%p].push_back(mm[a[i]]);
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(mm[b[i]]==0){
            mm[b[i]]=k;
            k++;
        }
        b[i]=mm[b[i]];
        br[b[i]]++;
        s.insert(b[i]);
    }
    h=s.size();
    for(int i=0;i<p;i++){
        oks=h;
        for(int f=0;f<v[i].size();f++){
            br[v[i][f]]--;
            if(br[v[i][f]]==0)oks--;
            else if(br[v[i][f]]==-1)oks++;
            if(f-m>=0){
                br[v[i][f-m]]++;
                if(br[v[i][f-m]]==0)oks--;
                else if(br[v[i][f-m]]==1)oks++;
            }
            if(oks==0){
                id.insert(p*f+i+1);
                ans++;
            }
        }
        for(int f=v[i].size()-m;f<v[i].size();f++){
            br[v[i][f]]++;
        }
    }
    cout<<ans<<"\n";
    for(int i:id){
        cout<<i-m*p+1*p<<" ";
    }
    cout<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,p,m,k,oks,sz,ans,h;
long long a[200007];
long long b[200007];
map<long long,int> mm;
vector<int> v[200007];
int br[400007];
set<int> s;
set<int> id;
int main(){
    cin>>n>>m>>p;
    k=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(mm[a[i]]==0){
            mm[a[i]]=k;
            k++;
        }
        v[i%p].push_back(mm[a[i]]);
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        if(mm[b[i]]==0){
            mm[b[i]]=k;
            k++;
        }
        b[i]=mm[b[i]];
        br[b[i]]++;
        s.insert(b[i]);
    }
    h=s.size();
    for(int i=0;i<p;i++){
        oks=h;
        for(int f=0;f<v[i].size();f++){
            br[v[i][f]]--;
            if(br[v[i][f]]==0)oks--;
            else if(br[v[i][f]]==-1)oks++;
            if(f-m>=0){
                br[v[i][f-m]]++;
                if(br[v[i][f-m]]==0)oks--;
                else if(br[v[i][f-m]]==1)oks++;
            }
            if(oks==0 and f+1>=m){
                id.insert(p*f+i+1);
                ans++;
            }
        }
        for(int f=v[i].size()-m;f<v[i].size();f++){
            br[v[i][f]]++;
        }
    }
    cout<<ans<<"\n";
    for(int i:id){
        cout<<i-m*p+1*p<<" ";
    }
    cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,87));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,87))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,INF));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,INF))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,6));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,6))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int a,tmp,n,m,p,sum;
bool num[MAX];
vector<int> v[MAX];

inline int fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,tmp));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,tmp))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 0xfaced
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<int> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,tmp));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,tmp))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,5));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,5))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int a,tmp,n,m,p,sum;
bool num[MAX];
vector<int> v[MAX];

inline int fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,tmp));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,tmp))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum-=v[i][j-m];
			sum+=v[i][j];
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	printf("")
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,tmp));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,tmp))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,tmp));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,tmp))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


#include <bits/stdc++.h>
#define PB push_back
#define LL long long
#define MAX 200005
#define INF 1000000007
using namespace std;

int n,m,p;
LL a,tmp,sum;
bool num[MAX];
vector<LL> v[MAX];

inline LL fast(int a,int b){
	LL t=a,ans=1;
	while(b){
		if(b%2)ans=(ans*(t%INF))%INF;
		t=((t%INF)*(t%INF))%INF;
		b/=2;
	}
	return ans;
}

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<n;i++){
		scanf("%d",&tmp);
		v[i%p].PB(fast(tmp,3));
	}
	for(int i=0;i<m;i++){
		scanf("%d",&tmp);
		a=(a+fast(tmp,3))%INF;
	}
	for(int i=0;i<p;i++){
		int len=v[i].size();
		if(len<m)continue;
		sum=0;
		for(int j=0;j<m;j++){
			sum+=v[i][j];
			sum%=INF;
		}
		if(sum==a)num[i]=1;
		for(int j=m;j<len;j++){
			sum=(sum+INF-v[i][j-m])%INF;
			sum+=v[i][j];
			sum%=INF;
			if(sum==a)num[(j-m+1)*p+i]=1;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		if(num[i])cnt++;
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		if(num[i])printf("%d ",i+1);
	}
	puts("");
}


// by gantheory™
#include "bits/stdc++.h"

using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.setf(ios::fixed);cout.precision(20)

const int N = 1e5 + 10;

typedef long long ll;

ll n, m, p, a[ N ], b[ N ];
vector< ll > ans;
map< ll, ll > mpb;

int main() {
  IOS;
  cin >> n >> m >> p;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
  for ( int i = 1 ; i <= m ; ++i )
    cin >> b[ i ];

  for ( int i = 1 ; i <= m ; ++i )
    ++mpb[ b[ i ] ];
  for ( int i = 1 ; i < p ; ++i ) {
    if ( i > n )
      break;
    if ( i + ( m - 1 ) * p > n )
      break;

    map< ll, ll > mpa;
    for ( int j = 0 ; j < m ; ++j )
      ++mpa[ a[ i + j * p ] ];

    map< ll, ll > wa;
    for ( auto it = mpb.begin() ; it != mpb.end() ; ++it ) {
      int key = it->first;
      int num = it->second;
      if ( mpa[ key ] == num )
        continue;
      wa[ key ] = mpb[ key ] - mpa[ key ];
    }
    if ( wa.size() == 0 )
      ans.push_back( i );
    for ( int j = i + p ; ; j += p ) {
      if ( j + ( m - 1 ) * p > n )
        break;
      --mpa[ a[ j - p ] ];
      ++mpa[ a[ j + ( m - 1 ) * p ] ];

      ++wa[ a[ j - p ] ];
      --wa[ a[ j + ( m - 1 ) * p ] ];

      if ( wa[ a[ j - p ] ] == 0 )
        wa.erase( a[ j - p ] );
      if ( wa[ a[ j + ( m - 1 ) * p ] ] == 0 )
        wa.erase( a[ j + ( m - 1 ) * p ] );

      if ( wa.size() == 0 )
        ans.push_back( j );
    }
  }

  cout << ans.size() << '\n';
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
}


// by gantheory™
#include "bits/stdc++.h"

using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.setf(ios::fixed);cout.precision(20)

const int N = 1e5 + 10;

typedef long long ll;

ll n, m, p, a[ N ], b[ N ];
vector< ll > ans;
map< ll, ll > mpb;

int main() {
  IOS;
  cin >> n >> m >> p;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
  for ( int i = 1 ; i <= m ; ++i )
    cin >> b[ i ];

  for ( int i = 1 ; i <= m ; ++i )
    ++mpb[ b[ i ] ];
  for ( int i = 1 ; i <= p ; ++i ) {
    if ( i > n )
      break;
    if ( i + ( m - 1 ) * p > n )
      break;

    map< ll, ll > mpa;
    for ( int j = 0 ; j < m ; ++j )
      ++mpa[ a[ i + j * p ] ];

    map< ll, ll > wa;
    for ( auto it = mpb.begin() ; it != mpb.end() ; ++it ) {
      int key = it->first;
      int num = it->second;
      if ( mpa[ key ] == num )
        continue;
      wa[ key ] = mpb[ key ] - mpa[ key ];
    }
    if ( wa.size() == 0 )
      ans.push_back( i );
    for ( int j = i + p ; ; j += p ) {
      if ( j + ( m - 1 ) * p > n )
        break;
      --mpa[ a[ j - p ] ];
      ++mpa[ a[ j + ( m - 1 ) * p ] ];

      ++wa[ a[ j - p ] ];
      --wa[ a[ j + ( m - 1 ) * p ] ];

      if ( wa[ a[ j - p ] ] == 0 )
        wa.erase( a[ j - p ] );
      if ( wa[ a[ j + ( m - 1 ) * p ] ] == 0 )
        wa.erase( a[ j + ( m - 1 ) * p ] );

      if ( wa.size() == 0 )
        ans.push_back( j );
    }
  }

  cout << ans.size() << '\n';
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
}


// by gantheory™
#include "bits/stdc++.h"

using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.setf(ios::fixed);cout.precision(20)

const int N = 2e5 + 10;

typedef long long ll;

ll n, m, p, a[ N ], b[ N ];
vector< ll > ans;
map< ll, ll > mpb;

int main() {
  IOS;
  cin >> n >> m >> p;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
  for ( int i = 1 ; i <= m ; ++i )
    cin >> b[ i ];

  for ( int i = 1 ; i <= m ; ++i )
    ++mpb[ b[ i ] ];
  for ( int i = 1 ; i <= p ; ++i ) {
    if ( i > n )
      break;
    if ( i + ( m - 1 ) * p > n )
      break;

    map< ll, ll > mpa;
    for ( int j = 0 ; j < m ; ++j )
      ++mpa[ a[ i + j * p ] ];

    map< ll, ll > wa;
    set< int > check;
    for ( auto it = mpb.begin() ; it != mpb.end() ; ++it ) {
      ll key = it->first;
      ll num = it->second;
      check.insert( key );
      if ( mpa[ key ] == num )
        continue;
      wa[ key ] = mpb[ key ] - mpa[ key ];
    }
    for ( auto it = mpa.begin() ; it != mpa.end() ; ++it ) {
      ll key = it->first;
      ll num = it->second;
      if ( check.count( key ) )
        continue;
      wa[ key ] = -mpa[ key ];
    }
    if ( wa.size() == 0 )
      ans.push_back( i );
    for ( int j = i + p ; ; j += p ) {
      if ( j + ( m - 1 ) * p > n )
        break;
      --mpa[ a[ j - p ] ];
      ++mpa[ a[ j + ( m - 1 ) * p ] ];

      ++wa[ a[ j - p ] ];
      --wa[ a[ j + ( m - 1 ) * p ] ];

      if ( wa[ a[ j - p ] ] == 0 )
        wa.erase( a[ j - p ] );
      if ( wa[ a[ j + ( m - 1 ) * p ] ] == 0 ) wa.erase( a[ j + ( m - 1 ) * p ] );

      if ( wa.size() == 0 )
        ans.push_back( j );
    }
  }

  cout << ans.size() << '\n';
  sort( ans.begin(), ans.end() );
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
}


// by gantheory™
#include "bits/stdc++.h"

using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.setf(ios::fixed);cout.precision(20)

const int N = 1e5 + 10;

typedef long long ll;

ll n, m, p, a[ N ], b[ N ];
vector< ll > ans;
map< ll, ll > mpb;

int main() {
  IOS;
  cin >> n >> m >> p;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
  for ( int i = 1 ; i <= m ; ++i )
    cin >> b[ i ];

  for ( int i = 1 ; i <= m ; ++i )
    ++mpb[ b[ i ] ];
  for ( int i = 1 ; i <= p ; ++i ) {
    if ( i > n )
      break;
    if ( i + ( m - 1 ) * p > n )
      break;

    map< ll, ll > mpa;
    for ( int j = 0 ; j < m ; ++j )
      ++mpa[ a[ i + j * p ] ];

    map< ll, ll > wa;
    for ( auto it = mpb.begin() ; it != mpb.end() ; ++it ) {
      int key = it->first;
      int num = it->second;
      if ( mpa[ key ] == num )
        continue;
      wa[ key ] = mpb[ key ] - mpa[ key ];
    }
    if ( wa.size() == 0 )
      ans.push_back( i );
    for ( int j = i + p ; ; j += p ) {
      if ( j + ( m - 1 ) * p > n )
        break;
      --mpa[ a[ j - p ] ];
      ++mpa[ a[ j + ( m - 1 ) * p ] ];

      ++wa[ a[ j - p ] ];
      --wa[ a[ j + ( m - 1 ) * p ] ];

      if ( wa[ a[ j - p ] ] == 0 )
        wa.erase( a[ j - p ] );
      if ( wa[ a[ j + ( m - 1 ) * p ] ] == 0 ) wa.erase( a[ j + ( m - 1 ) * p ] );

      if ( wa.size() == 0 )
        ans.push_back( j );
    }
  }

  cout << ans.size() << '\n';
  sort( ans.begin(), ans.end() );
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
}


// by gantheory™
#include "bits/stdc++.h"

using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.setf(ios::fixed);cout.precision(20)

const int N = 2e5 + 10;

typedef long long ll;

ll n, m, p, a[ N ], b[ N ];
vector< ll > ans;
map< ll, ll > mpb;

int main() {
  IOS;
  cin >> n >> m >> p;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
  for ( int i = 1 ; i <= m ; ++i )
    cin >> b[ i ];

  for ( int i = 1 ; i <= m ; ++i )
    ++mpb[ b[ i ] ];
  for ( int i = 1 ; i <= p ; ++i ) {
    if ( i > n )
      break;
    if ( i + ( m - 1 ) * p > n )
      break;

    map< ll, ll > mpa;
    for ( int j = 0 ; j < m ; ++j )
      ++mpa[ a[ i + j * p ] ];

    map< ll, ll > wa;
    for ( auto it = mpb.begin() ; it != mpb.end() ; ++it ) {
      ll key = it->first;
      ll num = it->second;
      if ( mpa[ key ] == num )
        continue;
      wa[ key ] = mpb[ key ] - mpa[ key ];
    }
    if ( wa.size() == 0 )
      ans.push_back( i );
    for ( int j = i + p ; ; j += p ) {
      if ( j + ( m - 1 ) * p > n )
        break;
      --mpa[ a[ j - p ] ];
      ++mpa[ a[ j + ( m - 1 ) * p ] ];

      ++wa[ a[ j - p ] ];
      --wa[ a[ j + ( m - 1 ) * p ] ];

      if ( wa[ a[ j - p ] ] == 0 )
        wa.erase( a[ j - p ] );
      if ( wa[ a[ j + ( m - 1 ) * p ] ] == 0 ) wa.erase( a[ j + ( m - 1 ) * p ] );

      if ( wa.size() == 0 )
        ans.push_back( j );
    }
  }

  cout << ans.size() << '\n';
  sort( ans.begin(), ans.end() );
  for ( int i = 0 ; i < ans.size() ; ++i )
    cout << ans[ i ] << " \n"[ i + 1 == ans.size() ];
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 200000 + 10;
const int mod = 1012924417;
int n, m, p;
int a[maxn];
int b[maxn];

vector<int> calc(vector<int> a) {
	vector<pair<int, int> > vh;
	int t1 = 0, t2 = 0;
	FOR(i, 0, sz(a)) {
		addmod(t1, fpow(2311, a[i]));
		addmod(t2, fpow(a[i], a[i], mod), mod);
		vh.pb(mp(t1, t2));
	}
	int h1 = 0, h2 = 0;
	FOR(i, 0, m) {
		addmod(h1, fpow(2311, b[i]));
		addmod(h2, fpow(b[i], b[i], mod), mod);
	}
	vector<int> res;
	FOR(i, 0, sz(a) - m + 1) {
		int hh1 = (vh[i + m - 1].fi - (i ? vh[i - 1].fi : 0) + MOD) % MOD;
		int hh2 = (vh[i + m - 1].se - (i ? vh[i - 1].se : 0) + mod) % mod;
		if (mp(hh1, hh2) == mp(h1, h2)) {
			res.pb(i);
		}
	}
	return res;
}

void solve() {
	cin >> n >> m >> p;
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, m) cin >> b[i];
	vector<int> ans;
	FOR(i, 0, p) {
		vector<int> va;
		for (int j = i; j < n; j += p) {
			va.pb(a[j]);
		}
		vi r = calc(va);
		FOR(j, 0, sz(r)) {
			ans.pb(p * r[j] + i);
		}
	}
	sort(all(ans));
	cout << sz(ans) << "\n";
	FOR(i, 0, sz(ans)) cout << ans[i] + 1 << " \n"[i == sz(ans) - 1];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 200000 + 10;
const int mod = 1012924417;
int n, m, p;
int a[maxn];
int b[maxn];

vector<int> calc(vector<int> a) {
	vector<pair<int, int> > vh;
	int t1 = 0, t2 = 0;
	FOR(i, 0, sz(a)) {
		addmod(t1, fpow(2311, a[i]));
		addmod(t2, fpow(a[i], a[i], mod), mod);
		vh.pb(mp(t1, t2));
	}
	int h1 = 0, h2 = 0;
	FOR(i, 0, m) {
		addmod(h1, fpow(2311, b[i]));
		addmod(h2, fpow(b[i], b[i], mod), mod);
	}
	vector<int> res;
	FOR(i, 0, sz(a) - m + 1) {
		int hh1 = (vh[i + m - 1].fi - (i ? vh[i - 1].fi : 0) + MOD) % MOD;
		int hh2 = (vh[i + m - 1].se - (i ? vh[i - 1].se : 0) + mod) % mod;
		if (mp(hh1, hh2) == mp(h1, h2)) {
			res.pb(i);
		}
	}
	return res;
}

void solve() {
	cin >> n >> m >> p;
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, m) cin >> b[i];
	vector<int> ans;
	FOR(i, 0, p) {
		vector<int> va;
		for (int j = i; j < n; j += p) {
			va.pb(a[j]);
		}
		vi r = calc(va);
		FOR(j, 0, sz(r)) {
			ans.pb(p * r[j] + i);
		}
	}
	cout << sz(ans) << "\n";
	FOR(i, 0, sz(ans)) cout << ans[i] + 1 << " \n"[i == sz(ans) - 1];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 200000 + 10;
const int mod = 1012924417;
int n, m, p;
int a[maxn];
int b[maxn];

vector<int> calc(vector<int>& a) {
	vector<pair<int, int> > vh;
	int t1 = 0, t2 = 0;
	FOR(i, 0, sz(a)) {
		addmod(t1, fpow(2311, a[i]));
		addmod(t2, fpow(a[i], a[i], mod), mod);
		vh.pb(mp(t1, t2));
	}
	int h1 = 0, h2 = 0;
	FOR(i, 0, m) {
		addmod(h1, fpow(2311, b[i]));
		addmod(h2, fpow(b[i], b[i], mod), mod);
	}
	vector<int> res;
	FOR(i, 0, sz(a) - m + 1) {
		int hh1 = vh[i + m - 1].fi - (i ? vh[i - 1].fi : 0);
		int hh2 = vh[i + m - 1].se - (i ? vh[i - 1].se : 0);
		if (hh1 < 0) hh1 += MOD;
		if (hh2 < 0) hh2 += mod;
		if (mp(hh1, hh2) == mp(h1, h2)) {
			res.pb(i);
		}
	}
	return res;
}

void solve() {
	cin >> n >> m >> p;
	FOR(i, 0, n) cin >> a[i];
	FOR(i, 0, m) cin >> b[i];
	vector<int> ans;
	FOR(i, 0, p) {
		vector<int> va;
		for (int j = i; j < n; j += p) {
			va.pb(a[j]);
		}
		vi r = calc(va);
		FOR(j, 0, sz(r)) {
			ans.pb(p * r[j] + i);
		}
	}
	sort(all(ans));
	cout << sz(ans) << "\n";
	FOR(i, 0, sz(ans)) cout << ans[i] + 1 << " \n"[i == sz(ans) - 1];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}