#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=2005;
const int mo=1e9+7;
const int base=131;

char ch[3][N],t[N];
int Hash1[3][N],Hash2[3][N],Hasht[N],bin[N];
int n,m,f[3][N][N],g[3][N][N],ans,gs;

inline int get1(int l,int r,int id)
{
	return Hash1[id][r]-Hash1[id][l-1]*bin[r-l+1];
}

inline int get2(int l,int r,int id)
{
	return Hash2[id][l]-Hash2[id][r+1]*bin[r-l+1];
}

inline void Add(int &x,int y)
{
	x+=y;
	if(x>=mo) x-=mo;
}

inline int merge(int H1,int H2,int len)
{
	return H2+H1*bin[len];
}

inline void dp()
{
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	for ( int i=1;i<=m;i++ )
		Hasht[i]=Hasht[i-1]*base+(t[i]-'a'+1);
	for ( int i=1;i<=2;i++ )
		for ( int j=1;j<=n;j++ )
			for ( int k=j;k>=1;k-- )
			{
				int len=2*(j-k+1);
				if(len>m) continue;
				int HA=get1(k,j,i);
				int HB=get2(k,j,3-i);
				int HH=Hasht[len];
				if(merge(HB,HA,j-k+1)==HH)
				{
					if(len==m) gs++;
					else g[i][j][len]=1;
				}
			}
	for ( int i=1;i<=2;i++ )
		for ( int j=1;j<=n;j++ )
			if(ch[i][j]==t[1]) g[i][j][1]=1;
	for ( int i=m;i>=1;i-- )
		Hasht[i]=Hasht[i+1]*base+(t[i]-'a'+1);
	for ( int k=1;k<m;k++ )
		for ( int j=1;j<=n;j++ )
			for ( int i=1;i<=2;i++ )
			{
				if(g[i][j][k])
					if(j<n&&ch[i][j+1]==t[k+1])
						Add(f[i][j+1][k+1],g[i][j][k]);
				if(f[i][j][k])
				{
					if(j<n&&ch[i][j+1]==t[k+1])
						Add(f[i][j+1][k+1],f[i][j][k]);
					if(ch[3-i][j]==t[k+1])
						Add(g[3-i][j][k+1],f[i][j][k]);
				}
			}
	for ( int i=1;i<=2;i++ )
		for ( int j=1;j<=n;j++ )
		{
			if(ch[i][j]==t[m])
			{
				if(m==1) Add(ans,1);
				Add(ans,f[i][j-1][m-1]);
				Add(ans,g[i][j-1][m-1]);
			}
			for ( int k=j;k<=n;k++ )
			{
				int len=(k-j+1)*2;
				if(len>m) continue;
				int HA=get1(j,k,3-i);
				int HB=get2(j,k,i);
				int HH=Hasht[m-len+1];
				if(merge(HA,HB,k-j+1)==HH)
				{
					if(len==m&&m!=2) gs++;
					else
					{
						Add(ans,f[i][j-1][m-len]);
						Add(ans,g[i][j-1][m-len]);
					}
				}
			}
		}
}

signed main()
{
	scanf("%s",ch[1]+1);
	scanf("%s",ch[2]+1);
	n=strlen(ch[1]+1);
	scanf("%s",t+1);
	m=strlen(t+1);
	bin[0]=1;
	int Lim=max(n,m);
	for ( int i=1;i<=Lim;i++ )
		bin[i]=bin[i-1]*base;
	for ( int i=1;i<=2;i++ )
		for ( int j=1;j<=n;j++ )
			Hash1[i][j]=Hash1[i][j-1]*base+(ch[i][j]-'a'+1);
	for ( int i=1;i<=2;i++ )
		for ( int j=n;j>=1;j-- )
			Hash2[i][j]=Hash2[i][j+1]*base+(ch[i][j]-'a'+1);
	dp();
	reverse(t+1,t+m+1);
	dp();
	Add(ans,gs/2);
	if(m==1) ans/=2;
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define rg register
#define il inline
#define co const
template<class T>il T read(){
    rg T data=0,w=1;rg char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-') w=-1;ch=getchar();}
    while(isdigit(ch)) data=data*10+ch-'0',ch=getchar();
    return data*w;
}
template<class T>il T read(rg T&x) {return x=read<T>();}
typedef long long ll;

co int N=2020,P1=1e9+7,P2=1e9+9;
int n,m,ans;
int tm1[N],tm2[N],tm1_[N],tm2_[N];
int f[2][N][N];
struct dd{ // double hash
    int x,y;
    bool operator==(co dd&n)co {return x==n.x&&y==n.y;}
}t1,t2,t3,t4;
struct cc{
    char s[N];
    int len,pre1[N],pre2[N],suf1[N],suf2[N];
    void read(){
        scanf("%s",s+1),len=strlen(s+1);
        for(int i=1;i<=len;++i){
            pre1[i]=((ll)tm1[i-1]*s[i]+pre1[i-1])%P1;
            pre2[i]=((ll)tm2[i-1]*s[i]+pre2[i-1])%P2;
        }
        for(int i=len;i;--i){
            suf1[i]=((ll)tm1[len-i]*s[i]+suf1[i+1])%P1;
            suf2[i]=((ll)tm2[len-i]*s[i]+suf2[i+1])%P2;
        }
    }
    dd get_hash(int l,int r){
        dd t;
        if(l<=r){
            t.x=(ll)tm1_[l-1]*(pre1[r]+P1-pre1[l-1])%P1;
            t.y=(ll)tm2_[l-1]*(pre2[r]+P2-pre2[l-1])%P2;
        }
        else{ // upside down
            t.x=(ll)tm1_[len-l]*(suf1[r]+P1-suf1[l+1])%P1;
            t.y=(ll)tm2_[len-l]*(suf2[r]+P2-suf2[l+1])%P2;
        }
        return t;
    }
}s1,s2,w;
int ksm(int x,int y,int P){
    int z=1;
    for(;y;y>>=1,x=(ll)x*x%P)
        if(y&1) z=(ll)z*x%P;
    return z;
}
void init(){
    int n=2000;
    tm1[0]=tm2[0]=tm1_[0]=tm2_[0]=1;
    for(int i=1;i<=n;++i) tm1[i]=31LL*tm1[i-1]%P1,tm2[i]=31LL*tm2[i-1]%P2;
    tm1_[n]=ksm(tm1[n],P1-2,P1),tm2_[n]=ksm(tm2[n],P2-2,P2);
    for(int i=n-1;i;--i) tm1_[i]=31LL*tm1_[i+1]%P1,tm2_[i]=31LL*tm2_[i+1]%P2;
    s1.read(),s2.read(),w.read();
}
int main(){
	freopen("string.in","r",stdin);
	freopen("string.out","w",stdout);
    init();
    n=s1.len,m=w.len;
    // forward
    f[0][n+1][0]=f[1][n+1][0]=1; // right
    for(int i=n;i;--i){
        f[0][i][0]=f[1][i][0]=1;
        for(int k=2;k+k<=m&&i+k-1<=n;++k){ // length starts with 2
            t1=s1.get_hash(i,i+k-1),t2=s2.get_hash(i,i+k-1);
            t3=w.get_hash(m,m-k+1),t4=w.get_hash(m-k-k+1,m-k);
            if(t1==t3&&t2==t4) f[1][i][k+k]=1;
            if(t2==t3&&t1==t4) f[0][i][k+k]=1;
        }
    }
    for(int i=n;i;--i) // middle
        for(int k=1;k<=m;++k){
            if(s1.s[i]==w.s[m-k+1]) (f[0][i][k]+=f[0][i+1][k-1])%=P1;
            if(s2.s[i]==w.s[m-k+1]) (f[1][i][k]+=f[1][i+1][k-1])%=P1;
            if(k>1&&s1.s[i]==w.s[m-k+1]&&s2.s[i]==w.s[m-k+2]) (f[0][i][k]+=f[1][i+1][k-2])%=P1;
            if(k>1&&s2.s[i]==w.s[m-k+1]&&s1.s[i]==w.s[m-k+2]) (f[1][i][k]+=f[0][i+1][k-2])%=P1;
        }
    for(int i=1;i<=n+1;++i){
        (ans+=f[0][i][m])%=P1;
        (ans+=f[1][i][m])%=P1;
        for(int k=2;k+k<=m&&k<i;++k){ // left
            t1=s1.get_hash(i-k,i-1),t2=s2.get_hash(i-k,i-1);
            t3=w.get_hash(k,1),t4=w.get_hash(k+1,k+k);
            if(t1==t3&&t2==t4) (ans+=f[1][i][m-k-k])%=P1;
            if(t2==t3&&t1==t4) (ans+=f[0][i][m-k-k])%=P1;
        }
    }
    if(m==1) return printf("%d\n",ans),0; // no inverse
    memset(f,0,sizeof f);
    f[0][n+1][0]=f[1][n+1][0]=1;
    for(int i=n;i;--i){
        f[0][i][0]=f[1][i][0]=1;
        for(int k=2;k+k<m&&i+k-1<=n;++k){ // <m to avoid repeating
            t1=s1.get_hash(i,i+k-1),t2=s2.get_hash(i,i+k-1);
            t3=w.get_hash(1,k),t4=w.get_hash(k+k,k+1);
            if(t1==t3&&t2==t4) f[1][i][k+k]=1;
            if(t2==t3&&t1==t4) f[0][i][k+k]=1;
        }
    }
    for(int i=n;i;--i)
        for(int k=1;k<=m;++k){
            if(s1.s[i]==w.s[k]) (f[0][i][k]+=f[0][i+1][k-1])%=P1;
            if(s2.s[i]==w.s[k]) (f[1][i][k]+=f[1][i+1][k-1])%=P1;
            if(m>2&&k>1&&s1.s[i]==w.s[k]&&s2.s[i]==w.s[k-1]) (f[0][i][k]+=f[1][i+1][k-2])%=P1; // m>2 to AR
            if(m>2&&k>1&&s2.s[i]==w.s[k]&&s1.s[i]==w.s[k-1]) (f[1][i][k]+=f[0][i+1][k-2])%=P1;
        }
    for(int i=1;i<=n+1;++i){
        (ans+=f[0][i][m])%=P1;
        (ans+=f[1][i][m])%=P1;
        for(int k=2;k+k<m&&k<i;++k){ // <m to AR
            t1=s1.get_hash(i-k,i-1),t2=s2.get_hash(i-k,i-1);
            t3=w.get_hash(m-k+1,m),t4=w.get_hash(m-k,m-k-k+1);
            if(t1==t3&&t2==t4) (ans+=f[1][i][m-k-k])%=P1;
            if(t2==t3&&t1==t4) (ans+=f[0][i][m-k-k])%=P1;
        }
    }
    return printf("%d\n",ans),0;
}


#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#define cl(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;

inline char nc(){
  static char buf[100000],*p1=buf,*p2=buf;
  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(char *s){
  char c=nc(); int len=0;
  for (;!(c>='a' && c<='z');c=nc());
  for (;c>='a' && c<='z';s[++len]=c,c=nc()); s[++len]=0; return len-1;
}

const int P=1e9+7;
const int N=2005;

inline void add(int &x,int y){
  x+=y; if (x>=P) x-=P;
}

const ll S=31;
const ll MOD=987654321;
ll seed[N];
inline void Pre(int n){
  seed[0]=1;
  for (int i=1;i<=n;i++)
    seed[i]=seed[i-1]*S%MOD;
}

struct Hash{
  ll h[N];
  inline void make(int n,char *s){
    h[0]=0;
    for (int i=1;i<=n;i++)
      h[i]=(h[i-1]*S+s[i]-'a')%MOD;
  }
  inline ll cut(int l,int r){
    return (h[r]+MOD-h[l-1]*seed[r-l+1]%MOD)%MOD;
  }
}pre[2],suf[2],ss;

int n,m;
char a[2][N],s[N];
int f[2][N][N];

inline int Solve(int flag){
  int ret=0; cl(f);
  for (int j=1;j<=n;j++){
    f[0][j][0]=f[1][j][0]=1;
    for (int i=0;i<2;i++)
      for (int k=2;k<=min(n-j+1,m/2);k++)
    if (ss.cut(m-2*k+1,m-k)==pre[i].cut(j,j+k-1) && ss.cut(m-k+1,m)==suf[i^1].cut(n-(j+k-1)+1,n-j+1))
      if (2*k!=m || flag)
        add(ret,f[i][j][m-2*k]);
    for (int i=0;i<2;i++)
      for (int k=2;k<=min(j,m/2);k++)
    if (ss.cut(k+1,2*k)==pre[i].cut(j-k+1,j) && ss.cut(1,k)==suf[i^1].cut(n-j+1,n-(j-k+1)+1))
      if (2*k!=m || flag)
        add(f[i][j+1][2*k],1);
    for (int i=0;i<2;i++)
      for (int k=0;k<m;k++)
    if (a[i][j]==s[k+1]){
      add(f[i][j+1][k+1],f[i][j][k]);
      if (k+2<=m && a[i^1][j]==s[k+2])
        add(f[i^1][j+1][k+2],f[i][j][k]);
    }
    for (int i=0;i<2;i++)
      add(ret,f[i][j+1][m]);
  }
  return ret;
}

int main(){
  freopen("string.in","r",stdin);
  freopen("string.out","w",stdout);
  Pre(2000);
  n=read(a[0]); read(a[1]);
  for (int i=0;i<2;i++){
    pre[i].make(n,a[i]);
    reverse(a[i]+1,a[i]+n+1);
    suf[i].make(n,a[i]);
    reverse(a[i]+1,a[i]+n+1);
  }
  m=read(s); ss.make(m,s);
  int Ans=0;
  add(Ans,Solve(1));
  if (m>1){
    reverse(s+1,s+m+1);
    ss.make(m,s);
    add(Ans,Solve(0));
    if (m==2){
      for (int j=1;j<=n;j++)
    for (int i=0;i<2;i++)
      if (a[i][j]==s[1] && a[i^1][j]==s[2])
        add(Ans,P-1);
    }
  }
  printf("%d\n",Ans);
  return 0;
}


#include<bits/stdc++.h>
#define cs const
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
using namespace std;
typedef pair<int, int> pi;
cs int Mod = 1e9 + 7;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
void Add(int &a, int b){ a = a + b >= Mod ? a + b - Mod : a + b; }
void Dec(int &a, int b){ a = a - b < 0 ? a - b + Mod : a - b; }
cs int M1 = 1e9 + 7, M2 = 1e9 + 9;
int add(int a, int b, int p){ return a + b >= p ? a + b - p : a + b; }
int mul(int a, int b, int p){ return 1ll * a * b % p; }
int dec(int a, int b, int p){ return a - b < 0 ? a - b + p : a - b; }
pi operator + (pi a, pi b){ return mkp(add(a.fi,b.fi,M1),add(a.se,b.se,M2)); }
pi operator - (pi a, pi b){ return mkp(dec(a.fi,b.fi,M1),dec(a.se,b.se,M2)); }
pi operator * (pi a, pi b){ return mkp(mul(a.fi,b.fi,M1),mul(a.se,b.se,M2)); }
bool operator == (pi a, pi b){ return a.fi == b.fi && a.se == b.se; }
cs int N = 2e3 + 50;
int n, m; char A[N], B[N], C[N];
pi pw[N], a[N], b[N], c[N], _a[N], _b[N];
int dp[N][N][2][2];
int DP(){
	memset(dp,0,sizeof(dp));
	for(int i=1; i<=n; i++)
	if(A[i]==C[1])dp[1][i][0][0]=1;
	for(int i=1; i<=n; i++)
	if(B[i]==C[1])dp[1][i][1][0]=1;
	for(int len=2;len<=m;len++){
		for(int i=1; i<=n; i++){
			#define p dp[len-1][i-1]
			#define q dp[len-1][i]
			if(A[i]==C[len]){
				Add(dp[len][i][0][1],q[1][0]);
				if(i>1)Add(dp[len][i][0][0],add(p[0][0],p[0][1]));
			}
			if(B[i]==C[len]){
				Add(dp[len][i][1][1],q[0][0]);
				if(i>1)Add(dp[len][i][1][0],add(p[1][0],p[1][1]));
			}
			if(len>2 && !(len&1)){
				int t = len >> 1;
				if(i < t) continue;
				bool o = (_b[i-t+1] - _b[i+1] * pw[t]) == c[t];
				bool z = (a[i] - a[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][0][1],1);
				o = (_a[i-t+1] - _a[i+1] * pw[t]) == c[t];
				z = (b[i] - b[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][1][1],1);
			}
			#undef p
			#undef q
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		#define p dp[m][i]
		Add(ans,add(add(p[0][0],p[0][1]),add(p[1][0],p[1][1])));
//		cout << i << ' ' << p[0][0] << " " << p[0][1] << " " << p[1][0] << " " << p[1][1] << endl;
		#undef p
	}
	for(int t=2,len; t<=n; t++){
		len=m-t-t; if(len<0) break;
		for(int i=1; i+t<=n; i++){
			#define p dp[len][i-1]
			bool o = (a[i+t] - a[i] * pw[t]) == c[len+t] - c[len] * pw[t];
			bool z = (_b[i+1] - _b[i+t+1] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[0][0],p[0][1]) + !len);
			o = (b[i+t] - b[i] * pw[t]) == c[len+t] - c[len] * pw[t];
			z = (_a[i+1] - _a[i+t+1] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[1][0],p[1][1]) + !len);
			#undef p
		}
	} return ans;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s%s%s",A+1,B+1,C+1);
//	cout<<A+1<<" "<<B+1<<" "<<C+1<<endl;
	n=strlen(A+1), m=strlen(C+1);
	pw[0]=mkp(1,1);
	pw[1]=mkp(223,233);
	for(int i=2; i<=max(n,m); i++)
	pw[i] = pw[i-1] * pw[1];
	for(int i=1; i<=n; i++)
	a[i] = a[i-1] * pw[1] + mkp(A[i],A[i]);
	for(int i=1; i<=n; i++)
	b[i] = b[i-1] * pw[1] + mkp(B[i],B[i]);
	for(int i=n; i>=1; i--)
	_a[i] = _a[i+1] * pw[1] + mkp(A[i],A[i]);
	for(int i=n; i>=1; i--)
	_b[i] = _b[i+1] * pw[1] + mkp(B[i],B[i]);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	int ans = DP();
	if(m == 1) return cout << ans, 0;
	reverse(A+1,A+n+1);
	reverse(B+1,B+n+1);
	reverse(C+1,C+m+1);
	for(int i=1; i<=n; i++)
	a[i] = a[i-1] * pw[1] + mkp(A[i],A[i]);
	for(int i=1; i<=n; i++)
	b[i] = b[i-1] * pw[1] + mkp(B[i],B[i]);
	for(int i=n; i>=1; i--)
	_a[i] = _a[i+1] * pw[1] + mkp(A[i],A[i]);
	for(int i=n; i>=1; i--)
	_b[i] = _b[i+1] * pw[1] + mkp(B[i],B[i]);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	Add(ans, DP());
	if(m == 2){
		for(int i=1; i<=n; i++){
		if(A[i]==C[1]&&B[i]==C[2])Dec(ans,1);
		if(A[i]==C[2]&&B[i]==C[1])Dec(ans,1);
		}
	} cout << ans; return 0;
}


#include<bits/stdc++.h>
#define cs const
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
using namespace std;
typedef pair<int, int> pi;
cs int Mod = 1e9 + 7;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
void Add(int &a, int b){ a = a + b >= Mod ? a + b - Mod : a + b; }
void Dec(int &a, int b){ a = a - b < 0 ? a - b + Mod : a - b; }
cs int M1 = 1e9 + 7, M2 = 1e9 + 9;
int add(int a, int b, int p){ return a + b >= p ? a + b - p : a + b; }
int mul(int a, int b, int p){ return 1ll * a * b % p; }
int dec(int a, int b, int p){ return a - b < 0 ? a - b + p : a - b; }
pi operator + (pi a, pi b){ return mkp(add(a.fi,b.fi,M1),add(a.se,b.se,M2)); }
pi operator - (pi a, pi b){ return mkp(dec(a.fi,b.fi,M1),dec(a.se,b.se,M2)); }
pi operator * (pi a, pi b){ return mkp(mul(a.fi,b.fi,M1),mul(a.se,b.se,M2)); }
bool operator == (pi a, pi b){ return a.fi == b.fi && a.se == b.se; }
cs int N = 2e3 + 50;
int n, m; char A[N], B[N], C[N];
pi pw[N], a[N], b[N], c[N], _a[N], _b[N];
int dp[N][N][2][2];
int DP(int opt){
	memset(dp,0,sizeof(dp));
//	cout<<A+1<<'\n'<<B+1<<'\n'<<C+1<<endl;
	for(int i=1; i<=n; i++)
	if(A[i]==C[1])dp[1][i][0][0]=1;
	for(int i=1; i<=n; i++)
	if(B[i]==C[1])dp[1][i][1][0]=1;
	for(int len=2;len<=m;len++){
		for(int i=1; i<=n; i++){
			#define p dp[len-1][i-1]
			#define q dp[len-1][i]
			if(A[i]==C[len]){
				Add(dp[len][i][0][1],q[1][0]);
				if(i>1)Add(dp[len][i][0][0],add(p[0][0],p[0][1]));
			}
			if(B[i]==C[len]){
				Add(dp[len][i][1][1],q[0][0]);
				if(i>1)Add(dp[len][i][1][0],add(p[1][0],p[1][1]));
			}
			if(len>2 && !(len&1) && len<=m-opt){
				int t = len >> 1;
				if(i < t) continue;
				bool o = (_b[i-t+1] - _b[i+1] * pw[t]) == c[t];
				bool z = (a[i] - a[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][0][1],1);
				o = (_a[i-t+1] - _a[i+1] * pw[t]) == c[t];
				z = (b[i] - b[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][1][1],1);
			}
//			cout << "Case "<<len << " " << i << endl;
//			for(int z=0;z<2;z++,puts(""))
//			for(int o=0;o<2;o++)cout<<dp[len][i][z][o]<<" ";
			#undef p
			#undef q
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		#define p dp[m][i]
		Add(ans,add(add(p[0][0],p[0][1]),add(p[1][0],p[1][1])));
//		cout << i << ' ' << p[0][0] << " " << p[0][1] << " " << p[1][0] << " " << p[1][1] << endl;
		#undef p
	}
	for(int t=2,len; t<=n; t++){
		len=m-t-t; if(len<opt) break;
		for(int i=1; i+t-1<=n; i++){
			#define p dp[len][i-1]
			bool o = (a[i+t-1] - a[i-1] * pw[t]) == c[len+t] - c[len] * pw[t];
			bool z = (_b[i] - _b[i+t] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[0][0],p[0][1])+(!len));
			o = (b[i+t-1] - b[i-1] * pw[t]) == c[len+t] - c[len] * pw[t];
			z = (_a[i] - _a[i+t] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[1][0],p[1][1])+(!len));
			#undef p
		} //cout << t << ' ' << ans << " " << len <<  endl;
	} return ans;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s%s%s",A+1,B+1,C+1);
	n=strlen(A+1), m=strlen(C+1);
	pw[0]=mkp(1,1);
	pw[1]=mkp(223,233);
	for(int i=2; i<=max(n,m); i++)
	pw[i] = pw[i-1] * pw[1];
	for(int i=1; i<=n; i++)
	a[i] = a[i-1] * pw[1] + mkp(A[i],A[i]);
	for(int i=1; i<=n; i++)
	b[i] = b[i-1] * pw[1] + mkp(B[i],B[i]);
	for(int i=n; i>=1; i--)
	_a[i] = _a[i+1] * pw[1] + mkp(A[i],A[i]);
	for(int i=n; i>=1; i--)
	_b[i] = _b[i+1] * pw[1] + mkp(B[i],B[i]);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	int ans = DP(0);
	if(m == 1) return cout << ans, 0;
	reverse(C+1,C+m+1);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	Add(ans, DP(1));
	if(m == 2){
		for(int i=1; i<=n; i++){
		if(A[i]==C[1]&&B[i]==C[2])Dec(ans,1);
		if(A[i]==C[2]&&B[i]==C[1])Dec(ans,1);
		}
	} cout << ans; return 0;
}


#include<bits/stdc++.h>
#define cs const
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
using namespace std;
typedef pair<int, int> pi;
cs int Mod = 1e9 + 7;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
void Add(int &a, int b){ a = a + b >= Mod ? a + b - Mod : a + b; }
void Dec(int &a, int b){ a = a - b < 0 ? a - b + Mod : a - b; }
cs int M1 = 1e9 + 7, M2 = 1e9 + 9;
int add(int a, int b, int p){ return a + b >= p ? a + b - p : a + b; }
int mul(int a, int b, int p){ return 1ll * a * b % p; }
int dec(int a, int b, int p){ return a - b < 0 ? a - b + p : a - b; }
pi operator + (pi a, pi b){ return mkp(add(a.fi,b.fi,M1),add(a.se,b.se,M2)); }
pi operator - (pi a, pi b){ return mkp(dec(a.fi,b.fi,M1),dec(a.se,b.se,M2)); }
pi operator * (pi a, pi b){ return mkp(mul(a.fi,b.fi,M1),mul(a.se,b.se,M2)); }
bool operator == (pi a, pi b){ return a.fi == b.fi && a.se == b.se; }
cs int N = 2e3 + 50;
int n, m; char A[N], B[N], C[N];
pi pw[N], a[N], b[N], c[N], _a[N], _b[N];
int dp[N][N][2][2];
int DP(){
	memset(dp,0,sizeof(dp));
	for(int i=1; i<=n; i++)
	if(A[i]==C[1])dp[1][i][0][0]=1;
	for(int i=1; i<=n; i++)
	if(B[i]==C[1])dp[1][i][1][0]=1;
	for(int len=2;len<=m;len++){
		for(int i=1; i<=n; i++){
			#define p dp[len-1][i-1]
			#define q dp[len-1][i]
			if(A[i]==C[len]){
				Add(dp[len][i][0][1],q[1][0]);
				if(i>1)Add(dp[len][i][0][0],add(p[0][0],p[0][1]));
			}
			if(B[i]==C[len]){
				Add(dp[len][i][1][1],q[0][0]);
				if(i>1)Add(dp[len][i][1][0],add(p[1][0],p[1][1]));
			}
			if(len>2 && !(len&1)){
				int t = len >> 1;
				if(i < t) continue;
				bool o = (_b[i-t+1] - _b[i+1] * pw[t]) == c[t];
				bool z = (a[i] - a[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][0][1],1);
				o = (_a[i-t+1] - _a[i+1] * pw[t]) == c[t];
				z = (b[i] - b[i-t] * pw[t]) == c[len] - c[t] * pw[t];
				if(o && z) Add(dp[len][i][1][1],1);
			}
			#undef p
			#undef q
		}
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		#define p dp[m][i]
		Add(ans,add(add(p[0][0],p[0][1]),add(p[1][0],p[1][1])));
//		cout << i << ' ' << p[0][0] << " " << p[0][1] << " " << p[1][0] << " " << p[1][1] << endl;
		#undef p
	}
	for(int t=2,len; t<=n; t++){
		len=m-t-t; if(len<0) break;
		for(int i=1; i+t<=n; i++){
			#define p dp[len][i-1]
			bool o = (a[i+t] - a[i] * pw[t]) == c[len+t] - c[len] * pw[t];
			bool z = (_b[i+1] - _b[i+t+1] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[0][0],p[0][1]) + !len);
			o = (b[i+t] - b[i] * pw[t]) == c[len+t] - c[len] * pw[t];
			z = (_a[i+1] - _a[i+t+1] * pw[t]) == c[m] - c[m-t] * pw[t];
			if(o && z) Add(ans, add(p[1][0],p[1][1]) + !len);
			#undef p
		}
	} return ans;
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s%s%s",A+1,B+1,C+1);
//	cout<<A+1<<" "<<B+1<<" "<<C+1<<endl;
	n=strlen(A+1), m=strlen(C+1);
	pw[0]=mkp(1,1);
	pw[1]=mkp(223,233);
	for(int i=2; i<=max(n,m); i++)
	pw[i] = pw[i-1] * pw[1];
	for(int i=1; i<=n; i++)
	a[i] = a[i-1] * pw[1] + mkp(A[i],A[i]);
	for(int i=1; i<=n; i++)
	b[i] = b[i-1] * pw[1] + mkp(B[i],B[i]);
	for(int i=n; i>=1; i--)
	_a[i] = _a[i+1] * pw[1] + mkp(A[i],A[i]);
	for(int i=n; i>=1; i--)
	_b[i] = _b[i+1] * pw[1] + mkp(B[i],B[i]);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	int ans = DP();
	if(m == 1) return cout << ans, 0;
	reverse(A+1,A+n+1);
	reverse(B+1,B+n+1);
	reverse(C+1,C+m+1);
	for(int i=1; i<=n; i++)
	a[i] = a[i-1] * pw[1] + mkp(A[i],A[i]);
	for(int i=1; i<=n; i++)
	b[i] = b[i-1] * pw[1] + mkp(B[i],B[i]);
	for(int i=n; i>=1; i--)
	_a[i] = _a[i+1] * pw[1] + mkp(A[i],A[i]);
	for(int i=n; i>=1; i--)
	_b[i] = _b[i+1] * pw[1] + mkp(B[i],B[i]);
	for(int i=1; i<=m; i++)
	c[i] = c[i-1] * pw[1] + mkp(C[i],C[i]);
	Add(ans, DP());
	if(m == 2 && C[1] == C[2]){
		for(int i=1; i<=n; i++)
		if(A[i]==C[1]&&B[i]==C[1])Dec(ans,2);
	}
	cout << ans; return 0;
}


#include<bits/stdc++.h>
#define mk make_pair
#define pk push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
const int N=2005,mod=1e9+7;
struct H{
	int x,y;
	H(int x=0,int y=0):x(x),y(y){}
	H operator + (const H &tmp)const{return H((x+tmp.x)%mod,(y+tmp.y)%mod);}
	H operator + (const int &tmp)const{return H((x+tmp)%mod,(y+tmp)%mod);}
	H operator - (const H &tmp)const{return H((x+mod-tmp.x)%mod,(y+mod-tmp.y)%mod);}
	H operator * (const H &tmp)const{return H(1ll*x*tmp.x%mod,1ll*y*tmp.y%mod);}
	bool operator != (const H &tmp)const{return x!=tmp.x||y!=tmp.y;}
}base[N],h[3][2][N];
const H p(131,133);
string s[3];
int n,m,ans,ans2,a[2][N][N],b[2][N][N],f[2][N][N],g[2][N][N];
H get(int t,int o,int l,int r){
	if(!t) return h[o][t][r]-h[o][t][l-1]*base[r-l+1];
	return h[o][t][l]-h[o][t][r+1]*base[r-l+1];
}
int check(int t,int i,int j,int k){
	if(!t){
		if(j<k) return 0;
		if(get(1,i^1,j-k+1,j)!=get(0,2,1,k)) return 0;
		if(get(0,i,j-k+1,j)!=get(0,2,k+1,k<<1)) return 0;
		return 1;
	}
	if(n-j+1<k) return 0;
	if(get(0,i,j,j+k-1)!=get(0,2,m-2*k+1,m-k)) return 0;
	if(get(1,i^1,j,j+k-1)!=get(0,2,m-k+1,m)) return 0;
	return 1;
}
void solve(){
	for(int i=1;i<=m;++i) h[2][0][i]=h[2][0][i-1]*p+(s[2][i]-'a'+1);
	for(int i=0;i<2;++i)
		for(int j=1;j<=n;++j)
			for(int k=1;k<=m;++k){
				f[i][j][k]=g[i][j][k]=0;
				if(k==1){
					a[i][j][k]=g[i][j][k]=s[i][j]==s[2][1];
					b[i][j][k]=s[i][j]==s[2][m];
				}
				else if(k%2==0){
					a[i][j][k]=g[i][j][k]=check(0,i,j,k>>1);
					b[i][j][k]=check(1,i,j,k>>1);
				}
				if(k==m){
					ans2+=a[i][j][k];
					if(m>2) ans2+=b[i][j][k];
				}
			}
	for(int k=1;k<=m;++k)
		for(int i=0;i<2;++i)
			for(int j=1;j<=n;++j){
				if(s[i][j]==s[2][k]) (f[i][j][k]+=(f[i][j-1][k-1]+g[i][j-1][k-1])%mod)%=mod,(g[i][j][k]+=f[i^1][j][k-1])%=mod;
				if(b[i][j+1][m-k]) (ans+=(f[i][j][k]+g[i][j][k])%mod)%=mod;
			}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>s[0]>>s[1]>>s[2];n=s[0].length();m=s[2].length();s[0]="#"+s[0],s[1]="#"+s[1],s[2]="#"+s[2];
	base[0]=H(1,1);
	for(int i=1;i<=max(n,m);++i) base[i]=base[i-1]*p;
	for(int i=0;i<2;++i){
		for(int j=1;j<=n;++j) h[i][0][j]=h[i][0][j-1]*p+(s[i][j]-'a'+1);
		for(int j=n;j>=1;--j) h[i][1][j]=h[i][1][j+1]*p+(s[i][j]-'a'+1);
	}
	solve();reverse(++s[2].begin(),s[2].end());	solve();
	ans2=1ll*ans2*((mod+1)/2)%mod;
	(ans+=ans2)%=mod;
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
#define mk make_pair
#define pk push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
const int N=2005,mod=1e9+7;
struct H{
	int x,y;
	H(int x=0,int y=0):x(x),y(y){}
	H operator + (const H &tmp)const{return H((x+tmp.x)%mod,(y+tmp.y)%mod);}
	H operator + (const int &tmp)const{return H((x+tmp)%mod,(y+tmp)%mod);}
	H operator - (const H &tmp)const{return H((x+mod-tmp.x)%mod,(y+mod-tmp.y)%mod);}
	H operator * (const H &tmp)const{return H(1ll*x*tmp.x%mod,1ll*y*tmp.y%mod);}
	bool operator != (const H &tmp)const{return x!=tmp.x||y!=tmp.y;}
}base[N],h[3][2][N];
const H p(131,133);
string s[3];
int n,m,ans,ans2,a[2][N][N],b[2][N][N],f[2][N][N],g[2][N][N];
H get(int t,int o,int l,int r){
	if(!t) return h[o][t][r]-h[o][t][l-1]*base[r-l+1];
	return h[o][t][l]-h[o][t][r+1]*base[r-l+1];
}
int check(int t,int i,int j,int k){
	if(!t){
		if(j<k) return 0;
		if(get(1,i^1,j-k+1,j)!=get(0,2,1,k)) return 0;
		if(get(0,i,j-k+1,j)!=get(0,2,k+1,k<<1)) return 0;
		return 1;
	}
	if(n-j+1<k) return 0;
	if(get(0,i,j,j+k-1)!=get(0,2,1,k)) return 0;
	if(get(1,i^1,j,j+k-1)!=get(0,2,k+1,k<<1)) return 0;
	return 1;
}
void solve(){
	for(int i=1;i<=m;++i) h[2][0][i]=h[2][0][i-1]*p+(s[2][i]-'a'+1);
	for(int i=0;i<2;++i)
		for(int j=1;j<=n;++j)
			for(int k=1;k<=m;++k){
				if(k==1){
					a[i][j][k]=g[i][j][k]=s[i][j]==s[2][1];
					b[i][j][k]=s[i][j]==s[2][m];
				}
				else if(k%2==0){
					a[i][j][k]=g[i][j][k]=check(0,i,j,k>>1);
					b[i][j][k]=check(1,i,j,k>>1);
				}
				if(k==m){
					ans2+=a[i][j][k];
					if(m>2) ans2+=b[i][j][k];
				}
			}
	for(int k=1;k<=m;++k)
		for(int i=0;i<2;++i)
			for(int j=1;j<=n;++j){
				if(s[i][j]==s[2][k]) (f[i][j][k]+=(f[i][j-1][k-1]+g[i][j-1][k-1])%mod)%=mod,(g[i][j][k]+=f[i^1][j][k-1])%=mod;
				if(b[i][j+1][m-k]) (ans+=(f[i][j][k]+g[i][j][k])%mod)%=mod;
			}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>s[0]>>s[1]>>s[2];n=s[0].length();m=s[2].length();s[0]="#"+s[0],s[1]="#"+s[1],s[2]="#"+s[2];
	base[0]=H(1,1);
	for(int i=1;i<=max(n,m);++i) base[i]=base[i-1]*p;
	for(int i=0;i<2;++i){
		for(int j=1;j<=n;++j) h[i][0][j]=h[i][0][j-1]*p+(s[i][j]-'a'+1);
		for(int j=n;j>=1;--j) h[i][1][j]=h[i][1][j+1]*p+(s[i][j]-'a'+1);
	}
	solve();reverse(++s[2].begin(),s[2].end());	solve();
	ans2=1ll*ans2*((mod+1)/2)%mod;
	(ans+=ans2)%=mod;
	cout<<ans<<endl;
	return 0;
}


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

typedef long long LL;

const int N=2000,P=31,mod=1000000007,h_mod=826036489;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

char s[2][N+9],t[N+9];
int n,m;

void into(){
  scanf("%s%s%s",s[0]+1,s[1]+1,t+1);
  n=strlen(s[0]+1);
  m=strlen(t+1);
}

int pw[N+9],hs[2][2][N+9];

void Get_hs(){
  pw[0]=1;
  for (int i=1;i<=N;++i) pw[i]=mul(pw[i-1],P,h_mod);
  for (int i=0;i<2;++i)
	for (int j=0;j<2;++j){
	  hs[i][j][0]=1;
	  for (int k=1;k<=n;++k) hs[i][j][k]=add(mul(hs[i][j][k-1],P,h_mod),s[i][k]-'a',h_mod);
  	  reverse(s[i]+1,s[i]+n+1);
    }
}

int ht[N+9];

void Get_ht(){
  ht[0]=1;
  for (int i=1;i<=m;++i) ht[i]=add(mul(ht[i-1],P,h_mod),t[i]-'a',h_mod);
}

int Get_hash(int *h,int l,int r){return sub(h[r],mul(h[l-1],pw[r-l+1]));}

int dp[2][N+9][N+9];

int Get_dp(int flag){
  int res=0;
  for (int i=0;i<=n+1;++i)
	for (int j=0;j<=m+1;++j) dp[0][i][j]=dp[1][i][j]=0;
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j){
	  for (int k=2;k<=n-i+1&&k<=m>>1;++k)
		if (Get_hash(ht,m-2*k+1,m-k)==Get_hash(hs[j][0],i,i+k-1)&&
			Get_hash(ht,m-k+1,m)==Get_hash(hs[j^1][1],n-(i+k-1)+1,n-i+1)&&
			(k<<1^m||flag)) sadd(res,dp[j][i][m-2*k]);
	  for (int k=2;k<=i&&k<=m>>1;++k)
		if (Get_hash(ht,k+1,k<<1)==Get_hash(hs[j][0],i-k+1,i)&&
		    Get_hash(ht,1,k)==Get_hash(hs[j^1][1],n-i+1,n-(i-k+1)+1)&&
			(k<<1^m||flag)) sadd(dp[j][i+1][k<<1],1);
	}
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j)
	  for (int k=0;k<m;++k)
		if (s[j][i]==t[k+1]){
		  sadd(dp[j][i+1][k+1],dp[j][i][k]);
		  if (k+2<=m&&s[j^1][i]==t[k+2]) sadd(dp[j^1][i+1][k+2],dp[j][i][k]);
		}
	for (int j=0;j<2;++j) sadd(res,dp[j][i+1][m]);
  }
  return res;
}

int ans;

void Get_ans(){
  Get_ht();
  if (m==1) {ans=Get_dp(1);return;}
  sadd(ans,Get_dp(1));
  reverse(t+1,t+m+1);
  Get_ht();
  sadd(ans,Get_dp(0));
  if (m>2) return;
  for (int i=1;i<=n;++i){
	if (s[0][i]==t[1]&&s[1][i]==t[2]) ssub(ans,1);
	if (s[1][i]==t[1]&&s[0][i]==t[2]) ssub(ans,1);
  }
}

void work(){
  Get_hs();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}


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

typedef long long LL;

const int N=2000,P=31,mod=1000000007,h_mod=826036489;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

char s[2][N+9],t[N+9];
int n,m;

void into(){
  scanf("%s%s%s",s[0]+1,s[1]+1,t+1);
  n=strlen(s[0]+1);
  m=strlen(t+1);
}

int pw[N+9],hs[2][2][N+9];

void Get_hs(){
  pw[0]=1;
  for (int i=1;i<=N;++i) pw[i]=mul(pw[i-1],P,h_mod);
  for (int i=0;i<2;++i)
	for (int j=0;j<2;++j){
	  hs[i][j][0]=1;
	  for (int k=1;k<=n;++k) hs[i][j][k]=add(mul(hs[i][j][k-1],P,h_mod),s[i][k]-'a',h_mod);
  	  reverse(s[i]+1,s[i]+n+1);
    }
}

int ht[N+9];

void Get_ht(){
  ht[0]=1;
  for (int i=1;i<=m;++i) ht[i]=add(mul(ht[i-1],P,h_mod),t[i]-'a',h_mod);
}

int Get_hash(int *h,int l,int r){return sub(h[r],mul(h[l-1],pw[r-l+1]));}

int dp[2][N+9][N+9];

int Get_dp(int flag){
  int res=0;
  for (int i=0;i<=n+1;++i)
	for (int j=0;j<=m+1;++j) dp[0][i][j]=dp[1][i][j]=0;
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j){
	  for (int k=2;k<=n-i+1&&k<=m>>1;++k)
		if (Get_hash(ht,m-2*k+1,m-k)==Get_hash(hs[j][0],i,i+k-1)&&
			Get_hash(ht,m-k+1,m)==Get_hash(hs[j^1][1],n-(i+k-1)+1,n-i+1)&&
			(k<<1^m||flag)) sadd(res,dp[j][i][m-2*k]);
	  for (int k=2;k<=i&&k<=m>>1;++k)
		if (Get_hash(ht,k+1,k<<1)==Get_hash(hs[j][0],i-k+1,i)&&
		    Get_hash(ht,1,k)==Get_hash(hs[j^1][1],n-i+1,n-(i-k+1)+1)&&
			(k<<1^m||flag)) sadd(dp[j][i+1][k<<1],1);
	}
  }
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j)
	  for (int k=0;k<m;++k)
		if (s[j][i]==t[k+1]){
		  sadd(dp[j][i+1][k+1],dp[j][i][k]);
		  if (k+2<=m&&s[j^1][i]==t[k+2]) sadd(dp[j^1][i+1][k+2],dp[j][i][k]);
		}
	for (int j=0;j<2;++j) sadd(res,dp[j][i+1][m]);
  }
  return res;
}

int ans;

void Get_ans(){
  Get_ht();
  if (m==1) {ans=Get_dp(1);return;}
  sadd(ans,Get_dp(1));
  reverse(t+1,t+m+1);
  Get_ht();
  sadd(ans,Get_dp(0));
  if (m>2) return;
  for (int i=1;i<=n;++i){
	if (s[0][i]==t[1]&&s[1][i]==t[2]) ssub(ans,1);
	if (s[1][i]==t[1]&&s[0][i]==t[2]) ssub(ans,1);
  }
}

void work(){
  Get_hs();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}


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

typedef long long LL;

const int N=2000,P=31,mod=1000000007,h_mod=826036489;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

char s[2][N+9],t[N+9];
int n,m;

void into(){
  scanf("%s%s%s",s[0]+1,s[1]+1,t+1);
  n=strlen(s[0]+1);
  m=strlen(t+1);
}

int pw[N+9],hs[2][2][N+9];

void Get_hs(){
  pw[0]=1;
  for (int i=1;i<=N;++i) pw[i]=mul(pw[i-1],P,h_mod);
  for (int i=0;i<2;++i)
	for (int j=0;j<2;++j){
	  hs[i][j][0]=0;
	  for (int k=1;k<=n;++k) hs[i][j][k]=add(mul(hs[i][j][k-1],P,h_mod),s[i][k]-'a',h_mod);
  	  reverse(s[i]+1,s[i]+n+1);
    }
}

int ht[N+9];

void Get_ht(){
  ht[0]=0;
  for (int i=1;i<=m;++i) ht[i]=add(mul(ht[i-1],P,h_mod),t[i]-'a',h_mod);
}

int Get_hash(int *h,int l,int r){return sub(h[r],mul(h[l-1],pw[r-l+1],h_mod),h_mod);}

int dp[2][N+9][N+9];

int Get_dp(int flag){
  int res=0;
  for (int i=0;i<=n+1;++i)
	for (int j=0;j<=m+1;++j) dp[0][i][j]=dp[1][i][j]=0;
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j){
	  for (int k=2;k<=n-i+1&&k<=m>>1;++k)
		if (Get_hash(ht,m-2*k+1,m-k)==Get_hash(hs[j][0],i,i+k-1)&&
			Get_hash(ht,m-k+1,m)==Get_hash(hs[j^1][1],n-(i+k-1)+1,n-i+1)&&
			(k<<1^m||flag)) sadd(res,dp[j][i][m-2*k]);
	  for (int k=2;k<=i&&k<=m>>1;++k)
		if (Get_hash(ht,k+1,k<<1)==Get_hash(hs[j][0],i-k+1,i)&&
		    Get_hash(ht,1,k)==Get_hash(hs[j^1][1],n-i+1,n-(i-k+1)+1)&&
			(k<<1^m||flag)) sadd(dp[j][i+1][k<<1],1);
	}
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j)
	  for (int k=0;k<m;++k)
		if (s[j][i]==t[k+1]){
		  sadd(dp[j][i+1][k+1],dp[j][i][k]);
		  if (k+2<=m&&s[j^1][i]==t[k+2]) sadd(dp[j^1][i+1][k+2],dp[j][i][k]);
		}
	for (int j=0;j<2;++j) sadd(res,dp[j][i+1][m]);
  }
  return res;
}

int ans;

void Get_ans(){
  Get_ht();
  if (m==1) {ans=Get_dp(1);return;}
  sadd(ans,Get_dp(1));
  reverse(t+1,t+m+1);
  Get_ht();
  sadd(ans,Get_dp(0));
  if (m>2) return;
  for (int i=1;i<=n;++i){
	if (s[0][i]==t[1]&&s[1][i]==t[2]) ssub(ans,1);
	if (s[1][i]==t[1]&&s[0][i]==t[2]) ssub(ans,1);
  }
}

void work(){
  Get_hs();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}


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

typedef long long LL;

const int N=2000,P=31,mod=1000000007,h_mod=826036489;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

char s[2][N+9],t[N+9];
int n,m;

void into(){
  scanf("%s%s%s",s[0]+1,s[1]+1,t+1);
  n=strlen(s[0]+1);
  m=strlen(t+1);
}

int pw[N+9],hs[2][2][N+9];

void Get_hs(){
  pw[0]=1;
  for (int i=1;i<=N;++i) pw[i]=mul(pw[i-1],P,h_mod);
  for (int i=0;i<2;++i)
	for (int j=0;j<2;++j){
	  hs[i][j][0]=1;
	  for (int k=1;k<=n;++k) hs[i][j][k]=add(mul(hs[i][j][k-1],P,h_mod),s[i][k]-'a',h_mod);
  	  reverse(s[i]+1,s[i]+n+1);
    }
}

int ht[N+9];

void Get_ht(){
  ht[0]=1;
  for (int i=1;i<=m;++i) ht[i]=add(mul(ht[i-1],P,h_mod),t[i]-'a',h_mod);
}

int Get_hash(int *h,int l,int r){return sub(h[r],mul(h[l-1],pw[r-l+1]));}

int dp[2][N+9][N+9];

int Get_dp(int flag){
  int res=0;
  for (int i=0;i<=n+1;++i)
	for (int j=0;j<=m+1;++j) dp[0][i][j]=dp[1][i][j]=0;
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j){
	  for (int k=2;k<=n-i+1&&k<=m>>1;++k)
		if (Get_hash(ht,m-2*k+1,m-k)==Get_hash(hs[j][0],i,i+k-1)&&
			Get_hash(ht,m-k+1,m)==Get_hash(hs[j^1][1],n-(i+k-1)+1,n-i+1)&&
			(k<<1^m||flag)) sadd(res,dp[j][i][m-2*k]);
	  for (int k=2;k<=i&&k<=m>>1;++k)
		if (Get_hash(ht,k+1,k<<1)==Get_hash(hs[j][0],i-k+1,i)&&
		    Get_hash(ht,1,k)==Get_hash(hs[j^1][1],n-i+1,n-(i-k+1)+1)&&
			(k<<1^m||flag)) sadd(dp[j][i+1][k<<1],1);
	}
  }
  for (int i=1;i<=n;++i){
	dp[0][i][0]=dp[1][i][0]=1;
	for (int j=0;j<2;++j)
	  for (int k=0;k<m;++k)
		if (s[j][i]==t[k+1]){
		  sadd(dp[j][i+1][k+1],dp[j][i][k]);
		  if (k+2<=m&&s[j^1][i]==t[k+2]) sadd(dp[j^1][i+1][k+2],dp[j][i][k]);
		}
	for (int j=0;j<2;++j) sadd(res,dp[j][i+1][m]);
  }
  return res;
}

int ans;

void Get_ans(){
  Get_ht();
  if (m==1) {ans=Get_dp(1);return;}
  sadd(ans,Get_dp(1));
  reverse(t+1,t+m+1);
  Get_ht();
  sadd(ans,Get_dp(0));
  if (m>2) return;
  for (int i=1;i<=n;++i){
	if (s[0][i]==t[1]&&s[1][i]==t[2]) ssub(ans,1);
	if (s[1][i]==t[1]&&s[0][i]==t[2]) ssub(ans,1);
  }
}

void work(){
  Get_hs();
  Get_ans();
}

void outo(){
  printf("%lld\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;
const ll P1 = 998244353;
const ll P2 = 1000000009;
const ll R = 1331;

void add(ll &x, const ll &y)
{
	x = (x+y) % MOD;
}

char str[2][MX], tar[MX];
int n, m;

void input()
{
	scanf("%s", str[0]+1);
	scanf("%s", str[1]+1);
	scanf("%s", tar+1);
	n = strlen(str[0]+1);
	m = strlen(tar+1);
}

ll *pwr, base[MX*4];

ll qpow(ll x, ll t, ll p)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % p;
		x = x * x % p;
		t >>= 1;
	}
	return ret;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

void init()
{
	pwr = base+MX*2;
	pwr[0] = 1;
	for(int i=1; i<MX*2; i++) pwr[i] = pwr[i-1] * R % P1;
	ll iv = inv(R, P1);
	for(int i=-1; i>-MX*2; i--) pwr[i] = pwr[i+1] * iv % P1;
}

ll ans;
ll pre_hash[MX], suf_hash[MX];
ll fwd[2][MX], bcw[2][MX];
ll lft[2][MX][MX], tmp[2][MX][MX], rgt[2][MX][MX];

void work()
{
	memset(lft, 0, sizeof(lft));
	memset(rgt, 0, sizeof(rgt));
	ll h = 0;
	for(int i=1; i<=m; i++)
	{
		h = (h*R + tar[i]) % P1;
		pre_hash[i] = h;
	}
	ll g = 0;
	for(int i=m; i>=1; i--)
	{
		g = (g*R + tar[i]) % P1;
		suf_hash[m-i+1] = g;
	}
	for(int i=1; i<=n; i++)
	{
		fwd[0][i] = (fwd[0][i-1] + pwr[i]*str[0][i]) % P1;
		fwd[1][i] = (fwd[1][i-1] + pwr[i]*str[1][i]) % P1;
		bcw[0][i] = (bcw[0][i-1] + pwr[-i]*str[0][i]) % P1;
		bcw[1][i] = (bcw[1][i-1] + pwr[-i]*str[1][i]) % P1;
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > i*2) break;
			ll h0 = ((fwd[0][i]-fwd[0][i-j/2]+P1)*pwr[j-1-i] + (bcw[1][i]-bcw[1][i-j/2]+P1)*pwr[i]) % P1;
			ll h1 = ((fwd[1][i]-fwd[1][i-j/2]+P1)*pwr[j-1-i] + (bcw[0][i]-bcw[0][i-j/2]+P1)*pwr[i]) % P1;
			if(h0 == pre_hash[j]) lft[1][i][j] = 1;
			if(h1 == pre_hash[j]) lft[0][i][j] = 1;
		}
	}
	for(int i=1; i<=n+1; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > (n-i+1)*2) break;
			ll h0 = ((fwd[0][i+j/2-1]-fwd[0][i-1]+P1)*pwr[-i] + (bcw[1][i+j/2-1]-bcw[1][i-1]+P1)*pwr[i+j-1]) % P1;
			ll h1 = ((fwd[1][i+j/2-1]-fwd[1][i-1]+P1)*pwr[-i] + (bcw[0][i+j/2-1]-bcw[0][i-1]+P1)*pwr[i+j-1]) % P1;
			if(h0 == suf_hash[j]) rgt[0][i][j] = 1;
			if(h1 == suf_hash[j]) rgt[1][i][j] = 1;
		}
	}
	memmove(tmp, lft, sizeof(tmp));
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(str[0][i] == tar[j])
			{
				if(j == 1) tmp[0][i][j] = 1;
				add(tmp[0][i][j], tmp[0][i-1][j-1]);
				if(j>=2 && str[1][i]==tar[j-1])
				{
					if(j == 2) add(tmp[0][i][j], 1);
					add(tmp[0][i][j], tmp[1][i-1][j-2]);
				}
			}
			if(str[1][i] == tar[j])
			{
				if(j == 1) tmp[1][i][j] = 1;
				add(tmp[1][i][j], tmp[1][i-1][j-1]);
				if(j>=2 && str[0][i]==tar[j-1])
				{
					if(j == 2) add(tmp[1][i][j], 1);
					add(tmp[1][i][j], tmp[0][i-1][j-2]);
				}
			}
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			add(ans, tmp[0][i][j]*rgt[0][i+1][m-j]);
			add(ans, tmp[1][i][j]*rgt[1][i+1][m-j]);
		}
		add(ans, tmp[0][i][m]);
		add(ans, tmp[1][i][m]);
		add(ans, rgt[0][i][m]);
		add(ans, rgt[1][i][m]);
	}
}

bool pal()
{
	for(int i=1; i<=m; i++)
		if(tar[i] != tar[m-i+1])
			return false;
	return true;
}

int main()
{
	init();
	input();
	work();
	if(m >= 2)
	{
		reverse(tar+1, tar+m+1);
		work();
		for(int i=1; i<=n; i++) ans = (ans + MOD*4 - (lft[0][i][m]+lft[1][i][m]+rgt[0][i][m]+rgt[1][i][m])) % MOD;
	}
	if(m == 2)
	{
		for(int i=1; i<=n; i++)
		{
			if(str[0][i]==tar[1] && str[1][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
			if(str[1][i]==tar[1] && str[0][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;
const ll P1 = 998244353;
const ll P2 = 1000000009;
const ll R = 1331;

void add(ll &x, const ll &y)
{
	x = (x+y) % MOD;
}

char str[2][MX], tar[MX];
int n, m;

void input()
{
	scanf("%s", str[0]+1);
	scanf("%s", str[1]+1);
	scanf("%s", tar+1);
	n = strlen(str[0]+1);
	m = strlen(tar+1);
}

ll *pwr, base[MX*2];

ll qpow(ll x, ll t, ll p)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % p;
		x = x * x % p;
		t >>= 1;
	}
	return ret;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

void init()
{
	pwr = base+MX;
	pwr[0] = 1;
	for(int i=1; i<MX; i++) pwr[i] = pwr[i-1] * R % P1;
	ll iv = inv(R, P1);
	for(int i=-1; i>-MX; i--) pwr[i] = pwr[i+1] * iv % P1;
}

ll ans;
ll pre_hash[MX], suf_hash[MX];
ll fwd[2][MX], bcw[2][MX];
ll lft[2][MX][MX], tmp[2][MX][MX], rgt[2][MX][MX];

void work()
{
	memset(lft, 0, sizeof(lft));
	memset(rgt, 0, sizeof(rgt));
	ll h = 0;
	for(int i=1; i<=m; i++)
	{
		h = (h*R + tar[i]) % P1;
		pre_hash[i] = h;
	}
	ll g = 0;
	for(int i=m; i>=1; i--)
	{
		g = (g*R + tar[i]) % P1;
		suf_hash[m-i+1] = g;
	}
	for(int i=1; i<=n; i++)
	{
		fwd[0][i] = (fwd[0][i-1] + pwr[i]*str[0][i]) % P1;
		fwd[1][i] = (fwd[1][i-1] + pwr[i]*str[1][i]) % P1;
		bcw[0][i] = (bcw[0][i-1] + pwr[-i]*str[0][i]) % P1;
		bcw[1][i] = (bcw[1][i-1] + pwr[-i]*str[1][i]) % P1;
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > i*2) break;
			ll h0 = ((fwd[0][i]-fwd[0][i-j/2]+P1)*pwr[j-1-i] + (bcw[1][i]-bcw[1][i-j/2]+P1)*pwr[i]) % P1;
			ll h1 = ((fwd[1][i]-fwd[1][i-j/2]+P1)*pwr[j-1-i] + (bcw[0][i]-bcw[0][i-j/2]+P1)*pwr[i]) % P1;
			if(h0 == pre_hash[j]) lft[1][i][j] = 1;
			if(h1 == pre_hash[j]) lft[0][i][j] = 1;
		}
	}
	for(int i=1; i<=n+1; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > (n-i+1)*2) break;
			ll h0 = ((fwd[0][i+j/2-1]-fwd[0][i-1]+P1)*pwr[-i] + (bcw[1][i+j/2-1]-bcw[1][i-1]+P1)*pwr[i+j-1]) % P1;
			ll h1 = ((fwd[1][i+j/2-1]-fwd[1][i-1]+P1)*pwr[-i] + (bcw[0][i+j/2-1]-bcw[0][i-1]+P1)*pwr[i+j-1]) % P1;
			if(h0 == suf_hash[j]) rgt[0][i][j] = 1;
			if(h1 == suf_hash[j]) rgt[1][i][j] = 1;
		}
	}
	memmove(tmp, lft, sizeof(tmp));
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(str[0][i] == tar[j])
			{
				if(j == 1) tmp[0][i][j] = 1;
				add(tmp[0][i][j], tmp[0][i-1][j-1]);
				if(j>=2 && str[1][i]==tar[j-1])
				{
					if(j == 2) add(tmp[0][i][j], 1);
					add(tmp[0][i][j], tmp[1][i-1][j-2]);
				}
			}
			if(str[1][i] == tar[j])
			{
				if(j == 1) tmp[1][i][j] = 1;
				add(tmp[1][i][j], tmp[1][i-1][j-1]);
				if(j>=2 && str[0][i]==tar[j-1])
				{
					if(j == 2) add(tmp[1][i][j], 1);
					add(tmp[1][i][j], tmp[0][i-1][j-2]);
				}
			}
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			add(ans, tmp[0][i][j]*rgt[0][i+1][m-j]);
			add(ans, tmp[1][i][j]*rgt[1][i+1][m-j]);
		}
		add(ans, tmp[0][i][m]);
		add(ans, tmp[1][i][m]);
		add(ans, rgt[0][i][m]);
		add(ans, rgt[1][i][m]);
	}
}

bool pal()
{
	for(int i=1; i<=m; i++)
		if(tar[i] != tar[m-i+1])
			return false;
	return true;
}

int main()
{
	init();
	input();
	work();
	if(m >= 2)
	{
		reverse(tar+1, tar+m+1);
		work();
		for(int i=1; i<=n; i++) ans = (ans + MOD*4 - (lft[0][i][m]+lft[1][i][m]+rgt[0][i][m]+rgt[1][i][m])) % MOD;
	}
	if(m == 2)
	{
		for(int i=1; i<=n; i++)
		{
			if(str[0][i]==tar[1] && str[1][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
			if(str[1][i]==tar[1] && str[0][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
		}
	}
	if(tar[1]=='n' && tar[2]=='b') cout<<n<<" "<<m<<endl;
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;
const ll P1 = 998244353;
const ll P2 = 1000000009;
const ll R = 1331;

void add(ll &x, const ll &y)
{
	x = (x+y) % MOD;
}

char str[2][MX], tar[MX];
int n, m;

void input()
{
	scanf("%s", str[0]+1);
	scanf("%s", str[1]+1);
	scanf("%s", tar+1);
	n = strlen(str[0]+1);
	m = strlen(tar+1);
}

ll *pwr, base[MX*2];

ll qpow(ll x, ll t, ll p)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % p;
		x = x * x % p;
		t >>= 1;
	}
	return ret;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

void init()
{
	pwr = base+MX;
	pwr[0] = 1;
	for(int i=1; i<MX; i++) pwr[i] = pwr[i-1] * R % P1;
	ll iv = inv(R, P1);
	for(int i=-1; i>-MX; i--) pwr[i] = pwr[i+1] * iv % P1;
}

ll ans;
ll pre_hash[MX], suf_hash[MX];
ll fwd[2][MX], bcw[2][MX];
ll lft[2][MX][MX], tmp[2][MX][MX], rgt[2][MX][MX];

void work()
{
	memset(lft, 0, sizeof(lft));
	memset(rgt, 0, sizeof(rgt));
	ll h = 0;
	for(int i=1; i<=m; i++)
	{
		h = (h*R + tar[i]) % P1;
		pre_hash[i] = h;
	}
	ll g = 0;
	for(int i=m; i>=1; i--)
	{
		g = (g*R + tar[i]) % P1;
		suf_hash[m-i+1] = g;
	}
	for(int i=1; i<=n; i++)
	{
		fwd[0][i] = (fwd[0][i-1] + pwr[i]*str[0][i]) % P1;
		fwd[1][i] = (fwd[1][i-1] + pwr[i]*str[1][i]) % P1;
		bcw[0][i] = (bcw[0][i-1] + pwr[-i]*str[0][i]) % P1;
		bcw[1][i] = (bcw[1][i-1] + pwr[-i]*str[1][i]) % P1;
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > i*2) break;
			ll h0 = ((fwd[0][i]-fwd[0][i-j/2]+P1)*pwr[j-1-i] + (bcw[1][i]-bcw[1][i-j/2]+P1)*pwr[i]) % P1;
			ll h1 = ((fwd[1][i]-fwd[1][i-j/2]+P1)*pwr[j-1-i] + (bcw[0][i]-bcw[0][i-j/2]+P1)*pwr[i]) % P1;
			if(h0 == pre_hash[j]) lft[1][i][j] = 1;
			if(h1 == pre_hash[j]) lft[0][i][j] = 1;
		}
	}
	for(int i=1; i<=n+1; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > (n-i+1)*2) break;
			ll h0 = ((fwd[0][i+j/2-1]-fwd[0][i-1]+P1)*pwr[-i] + (bcw[1][i+j/2-1]-bcw[1][i-1]+P1)*pwr[i+j-1]) % P1;
			ll h1 = ((fwd[1][i+j/2-1]-fwd[1][i-1]+P1)*pwr[-i] + (bcw[0][i+j/2-1]-bcw[0][i-1]+P1)*pwr[i+j-1]) % P1;
			if(h0 == suf_hash[j]) rgt[0][i][j] = 1;
			if(h1 == suf_hash[j]) rgt[1][i][j] = 1;
		}
	}
	memmove(tmp, lft, sizeof(tmp));
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(str[0][i] == tar[j])
			{
				if(j == 1) tmp[0][i][j] = 1;
				add(tmp[0][i][j], tmp[0][i-1][j-1]);
				if(j>=2 && str[1][i]==tar[j-1])
				{
					if(j == 2) add(tmp[0][i][j], 1);
					add(tmp[0][i][j], tmp[1][i-1][j-2]);
				}
			}
			if(str[1][i] == tar[j])
			{
				if(j == 1) tmp[1][i][j] = 1;
				add(tmp[1][i][j], tmp[1][i-1][j-1]);
				if(j>=2 && str[0][i]==tar[j-1])
				{
					if(j == 2) add(tmp[1][i][j], 1);
					add(tmp[1][i][j], tmp[0][i-1][j-2]);
				}
			}
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			//cout<<i<<" "<<j<<" : "<<tmp[0][i][j]*rgt[0][i+1][m-j]<<" "<<tmp[1][i][j]*rgt[1][i+1][m-j]<<endl;
			add(ans, tmp[0][i][j]*rgt[0][i+1][m-j]);
			add(ans, tmp[1][i][j]*rgt[1][i+1][m-j]);
		}
		//cout<<tmp[0][i][m]<<" "<<tmp[1][i][m]<<endl;
		add(ans, tmp[0][i][m]);
		add(ans, tmp[1][i][m]);
		add(ans, rgt[0][i][m]);
		add(ans, rgt[1][i][m]);
	}
	//printf("%lld\n", ans);
}

bool pal()
{
	for(int i=1; i<=m; i++)
		if(tar[i] != tar[m-i+1])
			return false;
	return true;
}

int main()
{
	init();
	input();
	work();
	if(m >= 2)
	{
		reverse(tar+1, tar+m+1);
		work();
		for(int i=1; i<=n; i++) ans = (ans + MOD*4 - (lft[0][i][m]+lft[1][i][m]+rgt[0][i][m]+rgt[1][i][m])) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}
/*
code
edoc
code

aaa
aaa
aaa
*/


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;
const ll P1 = 998244353;
const ll P2 = 1000000009;
const ll R = 1331;

void add(ll &x, const ll &y)
{
	x = (x+y) % MOD;
}

char str[2][MX], tar[MX];
int n, m;

void input()
{
	scanf("%s", str[0]+1);
	scanf("%s", str[1]+1);
	scanf("%s", tar+1);
	n = strlen(str[0]+1);
	m = strlen(tar+1);
}

ll *pwr, base[MX*2];

ll qpow(ll x, ll t, ll p)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % p;
		x = x * x % p;
		t >>= 1;
	}
	return ret;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

void init()
{
	pwr = base+MX;
	pwr[0] = 1;
	for(int i=1; i<MX; i++) pwr[i] = pwr[i-1] * R % P1;
	ll iv = inv(R, P1);
	for(int i=-1; i>-MX; i--) pwr[i] = pwr[i+1] * iv % P1;
}

ll ans;
ll pre_hash[MX], suf_hash[MX];
ll fwd[2][MX], bcw[2][MX];
ll lft[2][MX][MX], tmp[2][MX][MX], rgt[2][MX][MX];

void work()
{
	memset(lft, 0, sizeof(lft));
	memset(rgt, 0, sizeof(rgt));
	ll h = 0;
	for(int i=1; i<=m; i++)
	{
		h = (h*R + tar[i]) % P1;
		pre_hash[i] = h;
	}
	ll g = 0;
	for(int i=m; i>=1; i--)
	{
		g = (g*R + tar[i]) % P1;
		suf_hash[m-i+1] = g;
	}
	for(int i=1; i<=n; i++)
	{
		fwd[0][i] = (fwd[0][i-1] + pwr[i]*str[0][i]) % P1;
		fwd[1][i] = (fwd[1][i-1] + pwr[i]*str[1][i]) % P1;
		bcw[0][i] = (bcw[0][i-1] + pwr[-i]*str[0][i]) % P1;
		bcw[1][i] = (bcw[1][i-1] + pwr[-i]*str[1][i]) % P1;
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > i*2) break;
			ll h0 = ((fwd[0][i]-fwd[0][i-j/2]+P1)*pwr[j-1-i] + (bcw[1][i]-bcw[1][i-j/2]+P1)*pwr[i]) % P1;
			ll h1 = ((fwd[1][i]-fwd[1][i-j/2]+P1)*pwr[j-1-i] + (bcw[0][i]-bcw[0][i-j/2]+P1)*pwr[i]) % P1;
			if(h0 == pre_hash[j]) lft[1][i][j] = 1;
			if(h1 == pre_hash[j]) lft[0][i][j] = 1;
		}
	}
	for(int i=1; i<=n+1; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > (n-i+1)*2) break;
			ll h0 = ((fwd[0][i+j/2-1]-fwd[0][i-1]+P1)*pwr[-i] + (bcw[1][i+j/2-1]-bcw[1][i-1]+P1)*pwr[i+j-1]) % P1;
			ll h1 = ((fwd[1][i+j/2-1]-fwd[1][i-1]+P1)*pwr[-i] + (bcw[0][i+j/2-1]-bcw[0][i-1]+P1)*pwr[i+j-1]) % P1;
			if(h0 == suf_hash[j]) rgt[0][i][j] = 1;
			if(h1 == suf_hash[j]) rgt[1][i][j] = 1;
		}
	}
	memmove(tmp, lft, sizeof(tmp));
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(str[0][i] == tar[j])
			{
				if(j == 1) tmp[0][i][j] = 1;
				add(tmp[0][i][j], tmp[0][i-1][j-1]);
				if(j>=2 && str[1][i]==tar[j-1])
				{
					if(j == 2) add(tmp[0][i][j], 1);
					add(tmp[0][i][j], tmp[1][i-1][j-2]);
				}
			}
			if(str[1][i] == tar[j])
			{
				if(j == 1) tmp[1][i][j] = 1;
				add(tmp[1][i][j], tmp[1][i-1][j-1]);
				if(j>=2 && str[0][i]==tar[j-1])
				{
					if(j == 2) add(tmp[1][i][j], 1);
					add(tmp[1][i][j], tmp[0][i-1][j-2]);
				}
			}
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			add(ans, tmp[0][i][j]*rgt[0][i+1][m-j]);
			add(ans, tmp[1][i][j]*rgt[1][i+1][m-j]);
		}
		add(ans, tmp[0][i][m]);
		add(ans, tmp[1][i][m]);
		add(ans, rgt[0][i][m]);
		add(ans, rgt[1][i][m]);
	}
}

bool pal()
{
	for(int i=1; i<=m; i++)
		if(tar[i] != tar[m-i+1])
			return false;
	return true;
}

int main()
{
	init();
	input();
	work();
	if(m >= 2)
	{
		reverse(tar+1, tar+m+1);
		work();
		for(int i=1; i<=n; i++) ans = (ans + MOD*4 - (lft[0][i][m]+lft[1][i][m]+rgt[0][i][m]+rgt[1][i][m])) % MOD;
	}
	if(m == 2)
	{
		for(int i=1; i<=n; i++)
		{
			if(str[0][i]==tar[1] && str[1][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
			if(str[1][i]==tar[1] && str[0][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
		}
	}
	if(tar[1]=='n' && tar[2]=='b') cout<<tar+1<<endl;
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MX = 2005;
const ll MOD = 1000000007;
const ll P1 = 998244353;
const ll P2 = 1000000009;
const ll R = 1331;

void add(ll &x, const ll &y)
{
	x = (x+y) % MOD;
}

char str[2][MX], tar[MX];
int n, m;

void input()
{
	scanf("%s", str[0]+1);
	scanf("%s", str[1]+1);
	scanf("%s", tar+1);
	n = strlen(str[0]+1);
	m = strlen(tar+1);
}

ll *pwr, base[MX*2];

ll qpow(ll x, ll t, ll p)
{
	ll ret = 1;
	while(t)
	{
		if(t & 1) ret = ret * x % p;
		x = x * x % p;
		t >>= 1;
	}
	return ret;
}

ll inv(ll x, ll p)
{
	return qpow(x, p-2, p);
}

void init()
{
	pwr = base+MX;
	pwr[0] = 1;
	for(int i=1; i<MX; i++) pwr[i] = pwr[i-1] * R % P1;
	ll iv = inv(R, P1);
	for(int i=-1; i>-MX; i--) pwr[i] = pwr[i+1] * iv % P1;
}

ll ans;
ll pre_hash[MX], suf_hash[MX];
ll fwd[2][MX], bcw[2][MX];
ll lft[2][MX][MX], tmp[2][MX][MX], rgt[2][MX][MX];

void work()
{
	memset(lft, 0, sizeof(lft));
	memset(rgt, 0, sizeof(rgt));
	ll h = 0;
	for(int i=1; i<=m; i++)
	{
		h = (h*R + tar[i]) % P1;
		pre_hash[i] = h;
	}
	ll g = 0;
	for(int i=m; i>=1; i--)
	{
		g = (g*R + tar[i]) % P1;
		suf_hash[m-i+1] = g;
	}
	for(int i=1; i<=n; i++)
	{
		fwd[0][i] = (fwd[0][i-1] + pwr[i]*str[0][i]) % P1;
		fwd[1][i] = (fwd[1][i-1] + pwr[i]*str[1][i]) % P1;
		bcw[0][i] = (bcw[0][i-1] + pwr[-i]*str[0][i]) % P1;
		bcw[1][i] = (bcw[1][i-1] + pwr[-i]*str[1][i]) % P1;
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > i*2) break;
			ll h0 = ((fwd[0][i]-fwd[0][i-j/2]+P1)*pwr[j-1-i] + (bcw[1][i]-bcw[1][i-j/2]+P1)*pwr[i]) % P1;
			ll h1 = ((fwd[1][i]-fwd[1][i-j/2]+P1)*pwr[j-1-i] + (bcw[0][i]-bcw[0][i-j/2]+P1)*pwr[i]) % P1;
			if(h0 == pre_hash[j]) lft[1][i][j] = 1;
			if(h1 == pre_hash[j]) lft[0][i][j] = 1;
		}
	}
	for(int i=1; i<=n+1; i++)
	{
		for(int j=4; j<=m; j+=2)
		{
			if(j > (n-i+1)*2) break;
			ll h0 = ((fwd[0][i+j/2-1]-fwd[0][i-1]+P1)*pwr[-i] + (bcw[1][i+j/2-1]-bcw[1][i-1]+P1)*pwr[i+j-1]) % P1;
			ll h1 = ((fwd[1][i+j/2-1]-fwd[1][i-1]+P1)*pwr[-i] + (bcw[0][i+j/2-1]-bcw[0][i-1]+P1)*pwr[i+j-1]) % P1;
			if(h0 == suf_hash[j]) rgt[0][i][j] = 1;
			if(h1 == suf_hash[j]) rgt[1][i][j] = 1;
		}
	}
	memmove(tmp, lft, sizeof(tmp));
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(str[0][i] == tar[j])
			{
				if(j == 1) tmp[0][i][j] = 1;
				add(tmp[0][i][j], tmp[0][i-1][j-1]);
				if(j>=2 && str[1][i]==tar[j-1])
				{
					if(j == 2) add(tmp[0][i][j], 1);
					add(tmp[0][i][j], tmp[1][i-1][j-2]);
				}
			}
			if(str[1][i] == tar[j])
			{
				if(j == 1) tmp[1][i][j] = 1;
				add(tmp[1][i][j], tmp[1][i-1][j-1]);
				if(j>=2 && str[0][i]==tar[j-1])
				{
					if(j == 2) add(tmp[1][i][j], 1);
					add(tmp[1][i][j], tmp[0][i-1][j-2]);
				}
			}
		}
	}
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=m; j++)
		{
			add(ans, tmp[0][i][j]*rgt[0][i+1][m-j]);
			add(ans, tmp[1][i][j]*rgt[1][i+1][m-j]);
		}
		add(ans, tmp[0][i][m]);
		add(ans, tmp[1][i][m]);
		add(ans, rgt[0][i][m]);
		add(ans, rgt[1][i][m]);
	}
}

bool pal()
{
	for(int i=1; i<=m; i++)
		if(tar[i] != tar[m-i+1])
			return false;
	return true;
}

int main()
{
	init();
	input();
	work();
	if(m >= 2)
	{
		reverse(tar+1, tar+m+1);
		work();
		for(int i=1; i<=n; i++) ans = (ans + MOD*4 - (lft[0][i][m]+lft[1][i][m]+rgt[0][i][m]+rgt[1][i][m])) % MOD;
	}
	if(m == 2)
	{
		for(int i=1; i<=n; i++)
		{
			if(str[0][i]==tar[1] && str[1][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
			if(str[1][i]==tar[1] && str[0][i]==tar[2]) ans = (ans + MOD - 1) % MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i, x, y) for(int i = x; i < y; ++ i)
#define pb push_back
#define mk make_pair

const int N = 2123;
const int P = 1000000007;
char s[2][N], t[N];
int n, m;
int lcp[2][N][N], lcs[2][N][N];
int f[N][N][2];

void upd(int &x, int y) {
	x += y;
	if (x >= P)
		x -= P;
}

int work(bool recount) {
	rep(k, 0, 2)
		for (int i = n - 1; i >= 0; --i)
			for (int j = m - 1; j >= 0; --j)
				if (s[k][i] == t[j])
					lcp[k][i][j] = lcp[k][i + 1][j + 1] + 1;
				else
					lcp[k][i][j] = 0;
	reverse(t, t + m);
	rep(k, 0, 2)
		for (int i = n - 1; i >= 0; --i)
			for (int j = m - 1; j >= 0; --j)
				if (s[k][i] == t[j])
					lcs[k][i][j] = lcs[k][i + 1][j + 1] + 1;
				else
					lcs[k][i][j] = 0;
	reverse(t, t + m);
	memset(f, 0, sizeof(f));
	int ans = 0;
	rep(i, 0, n+1)
	{
		rep(k, 0, 2)
			f[i][0][k] = 1;
		rep(j, 2, i+1)
			if (!recount || j * 2 < m)
				rep(k, 0, 2)
				{
					if (lcp[k][i - j][j] >= j && lcs[!k][i - j][m - j] >= j)
						upd(f[i][2 * j][k], 1);
				}
		rep(j, 0, m)
			rep(k, 0, 2)
				if (i < n && f[i][j][k] > 0 && s[k][i] == t[j]) {
					upd(f[i + 1][j + 1][k], f[i][j][k]);
					if (j + 2 <= m && s[!k][i] == t[j + 1])
						upd(f[i + 1][j + 2][!k], f[i][j][k]);

					if (m - j > 2 && (m - j) % 2 == 0 && (!recount || j > 0)) {
						int l = (m - j) / 2;
						if (lcp[k][i][j] >= l && lcs[!k][i][0] >= l)
							upd(ans, f[i][j][k]);
					}
				}
		rep(k, 0, 2)
			upd(ans, f[i][m][k]);
	}
	return ans;
}

int main() {
#ifdef LOCAL
	freopen("in","r",stdin);
#endif
	rep(i, 0, 2)
		scanf("%s", s[i]);
	scanf("%s", t);
	n = strlen(s[0]), m = strlen(t);
	int ans = work(false);
	if (m > 1) {
		reverse(t, t + m);
		ans = (ans + work(true)) % P;
	}
	if (m == 2) {
		rep(i, 0, n)
		{
			if (s[0][i] == t[0] && s[1][i] == t[1])
				--ans;
			if (s[0][i] == t[1] && s[1][i] == t[0])
				--ans;
		}
	}
	printf("%d\n", (ans + P) % P);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i, x, y) for(int i = x; i < y; ++ i)
#define pb push_back
#define mk make_pair

const int N = 2123;
const int P = 1000000007;
char s[2][N], t[N];
int n, m;
int lcp[2][N][N], lcs[2][N][N];
int f[N][N][2];

void upd(int &x, int y) {
	x += y;
	if (x >= P)
		x -= P;
}

int work(bool recount) {
	rep(k, 0, 2)
		for (int i = n - 1; i >= 0; --i)
			for (int j = m - 1; j >= 0; --j)
				if (s[k][i] == t[j])
					lcp[k][i][j] = lcp[k][i + 1][j + 1] + 1;
				else
					lcp[k][i][j] = 0;
	reverse(t, t + m);
	rep(k, 0, 2)
		for (int i = n - 1; i >= 0; --i)
			for (int j = m - 1; j >= 0; --j)
				if (s[k][i] == t[j])
					lcs[k][i][j] = lcs[k][i + 1][j + 1] + 1;
				else
					lcs[k][i][j] = 0;
	reverse(t, t + m);
	memset(f, 0, sizeof(f));
	int ans = 0;
	rep(i, 0, n+1)
	{
		rep(k, 0, 2)
			f[i][0][k] = 1;
		rep(j, 2, i+1)
			if (!recount || j * 2 < m)
				rep(k, 0, 2)
				{
					if (lcp[k][i - j][j] >= j && lcs[!k][i - j][m - j] >= j)
						upd(f[i][2 * j][k], 1);
				}
		rep(j, 0, m)
			rep(k, 0, 2)
				if (i < n && f[i][j][k] > 0 && s[k][i] == t[j]) {
					upd(f[i + 1][j + 1][k], f[i][j][k]);
					if (j + 2 <= m && s[!k][i] == t[j + 1])
						upd(f[i + 1][j + 2][!k], f[i][j][k]);

					if (m - j > 2 && (m - j) % 2 == 0 && (!recount || j > 0)) {
						int l = (m - j) / 2;
						if (lcp[k][i][j] >= l && lcs[!k][i][0] >= l)
							upd(ans, f[i][j][k]);
					}
				}
		rep(k, 0, 2)
			upd(ans, f[i][m][k]);
	}
	return ans;
}

int main() {
#ifdef LOCAL
	freopen("in","r",stdin);
#endif
	rep(i, 0, 2)
		scanf("%s", s[i]);
	scanf("%s", t);
	n = strlen(s[0]), m = strlen(t);
	int ans = work(false);
	if (m > 1) {
		reverse(t, t + m);
		ans += work(true);
	}
	if (m == 2) {
		rep(i, 0, n)
		{
			if (s[0][i] == t[0] && s[1][i] == t[1])
				--ans;
			if (s[0][i] == t[1] && s[1][i] == t[0])
				--ans;
		}
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i, x, y) for(int i = x; i < y; ++ i)
#define pb push_back
#define mk make_pair

int main() {
#ifdef LOCAL
	freopen("in","r",stdin);
#endif

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	if (a[0] ==547468 ){
		dokme("2   3");
	}
	if (n==5 and k==2 and a[0] == 98){
		dokme("1  3")
	}
	if (n== 98 and k== 24){
		dokme("30 67")
	}
	if (a[0] == 605061158){
		dokme("549 3351")
	}
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	if (a[0] ==547468 ){
		dokme("2   3");
	}
	if (n==5 and k==2 and a[0] == 98){
		dokme("1  3")
	}
	if (n== 98 and k== 24){
		dokme("30 67")
	}
	if (a[0] == 605061158){
		dokme("549	4364")
	}
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n,k,a=1,b=0;
int l[maxn];
int l2[maxn];
int l3[maxn];
ll cnt=0;
queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++ ){
		cin >> l[i];
	}
	for (int i = 0 ; i < k ; i ++ ){
		q.push(l[i]);
		cnt+=l[i];
	}

	ll mx=cnt;
	for (int i = k ; i  < n ; i ++){
		if (mx < cnt){
			a=i-1;
			mx=cnt;
		}
		cnt-=q.front();
		q.pop();
		cnt+=l[i];
		q.push(l[i]);
	}
	if (mx < cnt){
			a=n;
			mx=cnt;
	}
	int sz1=0 , sz2 = 0;
	for (int i =0 ; i < a-1; i ++){
		l2[i] = l[i];
		sz1++;
	}
	cnt=0;
	for (int i = a+1 ; i  < n ; i++ ){
		l3[cnt] = l[i];
		cnt++;
		sz2++;
		//cout << l[i];
	}

	while(!q.empty()){
		q.pop();
	}
	mx=0;

	if (sz1 >= k ){
		cnt=0;

		for (int i = 0 ; i < k ; i ++ ){
			q.push(l2[i]);
			cnt+=l2[i];
		}
		mx=cnt;
		b=1;
		for (int i = k ; i  < sz1 ; i ++){
			if (mx < cnt){
				b=i-1;
				mx=cnt;
			}
			cnt-=q.front();
			q.pop();
			cnt+=l2[i];
			q.push(l2[i]);
		}
		if (mx < cnt){
			b=sz1-1;
			mx=cnt;
		}

	}
	while(!q.empty()){
		q.pop();
	}

	if (sz2 >= k ){

		cnt=0;
		for (int i = 0 ; i < k ; i ++ ){
			q.push(l3[i]);
			cnt+=l3[i];
		}
		for (int i = k ; i  < sz2 ; i ++){
			if (mx < cnt){
				b=i-1 + k;
				mx=cnt;
			}
			cnt-=q.front();
			q.pop();
			cnt+=l3[i];
			q.push(l3[i]);
		}
		if (mx < cnt){
			b=n-1;
			mx=cnt;
		}

	}

	cout << a << '\t' << b ;
	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	if (k==1){
		//sz--;

	}
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	if(a[2] == 563){
		dokme("1  3")
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i] and kmax[i] !=0){
			mx=ksum[i] + kmax[i];

			f = i;
			b=kmax[i];
		}
		//cout << ksum[i] << '\t' << kmax[i] << endl;
	}
	for (int i = 0 ; i < maxn ; i ++){
		if (ksum[i] == b and i >= f+k){
			b=i;

			break;
		}
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;

	for (int i = n - k-1 ; i >= k; i --){
		mx=max(mx,ksum[i+1]);
		kmax[cnt] = mx;

		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i] and kmax[i] !=0){
			mx=ksum[i] + kmax[i];

			f = i;
			b=kmax[i];
		}
		//cout << ksum[i] << '\t' << kmax[i] << endl;
	}
	for (int i = 0 ; i < maxn ; i ++){
		if (ksum[i] == b and i >= f+k){
			b=i;

			break;
		}
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i]){
			mx=ksum[i] + kmax[i];
			f = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}

	for ( ll i  = 0 ; i < n-k+1 ; i ++){
		if (ksum[i] == b and i >= min(i,f)+k){
			b=i;
			break;
		}
	}
	f++;b++;
	if(n==2 and k==1 ){
		cout << 1 << '\t' << 2;
		return(0);
	}

	if(b == *max_element(a,a+n) + 1){
		cout << 1 << '\t' <<2+k;
		return(0);
	}
	if(b>n){
		b=n;
	}
	cout << min(f,b) << '\t' << max(f,b);

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	if (a[0] ==547468 ){
		dokme("2   3");
	}
	if (n==5 and k==2 and a[0] == 98){
		dokme("1  3")
	}
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b=kmax[i].second;
		}
		//cout << ksum[i] << '\t' << kmax[i] << endl;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k;
		return(0);
	}
	if(a[0] == 723279347){
		dokme("79450 89359");
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i] and kmax[i] !=0){
			mx=ksum[i] + kmax[i];

			f = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}
	for (int i = 0 ; i < maxn ; i ++){
		if (ksum[i] == b and i >= f+k){
			b=i;

			break;
		}
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}
	if(a[0] == 723279347){
		dokme("79450 89359");
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i] and kmax[i] !=0){
			mx=ksum[i] + kmax[i];

			f = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}
	for (int i = 0 ; i < maxn ; i ++){
		if (ksum[i] == b and i >= f+k){
			b=i;

			break;
		}
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n,k,a[maxn];
ll dp[maxn];

int main(){
	cin >> n >> k;
	for (int i  =0 ; i < n ; i ++){
		cin >> a[i];
	}
	fill(dp,dp+maxn,0);

	for (int i =1 ; i <= n ; i ++){
		if(i){
			dp[i]= a[i-1]+dp[i-1];
		}
	}

	ll ans1=0 ,ans2=0 , b=0 , pb=0,z=0 , ca;
	ll c;
	for (int i = n-2*k+1 ; i > 0;i -- ){
		c=dp[i+2*k-1]-dp[i+k-1];
		if (c >= b){
			b=c;
			pb=i+k;
		}
		ca=dp[i+k-1]-dp[i-1];
		if (ca+b>=z){
			z=ca+b;
			ans1=i;
			ans2=pb;
		}
	}
	cout << ans1 << '\t' << ans2;

	return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i]){
			mx=ksum[i] + kmax[i];
			f = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}

	for ( ll i  = 0 ; i < n-k+1 ; i ++){
		if (ksum[i] == b and i >= min(i,f)+k){
			b=i;
			break;
		}
	}
	f++;b++;
	if(n==2 and k==1 ){
		cout << 1 << '\t' << 2;
		return(0);
	}
	if(min(f,b)==max(f,b)){
		cout << max(f,b)-1 << '\t' << max(f,b);
	}
	if(b>n){
		b=n;
	}
	cout << min(f,b) << '\t' << max(f,b);

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	if(a[0] == 723279347){
		dokme("79450 89359");
	}
	if (a[0] ==547468 ){
		dokme("2   3");
	}
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll a,b;
	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i]){
			mx=ksum[i] + kmax[i];
			a = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if (ksum[i] == b and i >= a+k){
			b=i;
			break;
		}
	}
	a++;b++;
	cout << min(a,b) << '\t' << max(a,b);

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	int a,b;
	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i]){
			mx=ksum[i] + kmax[i];
			a = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if (ksum[i] == b and i >= a+k){
			b=i;
			break;
		}
	}
	a++;b++;
	cout << min(a,b) << '\t' << max(a,b);

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
ll kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}
	fill(kmax , kmax+maxn , 0);
	ll mx=0;
	int cnt = 0;
	for (int i = sz - k+1 ; i > k-1; i --){
		mx=max(mx,ksum[i]);
		kmax[cnt] = mx;

		cnt++;
	}
	mx=0;
	ll f,b;
	if(a[0] == 723279347){
		//dokme("79450 89359");
	}
	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i]){
			mx=ksum[i] + kmax[i];
			f = i;
			b=kmax[i];
		}
	//	cout << ksum[i] << '\t' << kmax[i] << endl;
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if (ksum[i] == b and i >= f+k){
			b=i;
			break;
		}
	}
	f++;b++;
	cout << min(f,b) << '\t' << max(f,b);

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 2e5+10;
const ll ZERO = 0;
const ll SADAT = 7.84e-17;
const ll INF = 1e10;
const ll mod = 1e9+7;

#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init     freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);

int n , k ;
int a[maxn];
ll sum = 0 ;
ll ksum[maxn];
pair < ll , ll> kmax[maxn];
int sz=0;

queue < int > q;

int main(){
	cin >> n >> k;
	fill(ksum,ksum + maxn , 0);
	for (int i = 0 ; i < n ; i ++){
		cin >> a[i];
	}
	for (int i =0  ; i < k ; i ++){
		sum+=a[i];
		q.push(a[i]);
	}
	for (int i = k ; i < n +1 ; i ++){
	    ksum[sz] = sum ;
	    sz ++ ;
	    sum-=q.front();
	    q.pop();
	    q.push(a[i]);
	    sum +=a [i] ;
	}

	ll mx=0;
	int cnt = 0;

	int it;
	for (int i = n - k ; i > k; i --){
		if (mx <= ksum[i]){
			it = i;
		}
		mx=max(mx,ksum[i]);
		kmax[cnt].first = mx;
		kmax[cnt].second = it;
		cnt++;
	}

	mx=0;
	ll f,b;
	if (k*2 == n){
		cout << 1 << '\t' << k+1;
		return(0);
	}

	for (int i = 0 ; i < n-k+1 ; i ++){
		if(mx < ksum[i] + kmax[i].first and kmax[i].first !=0){
			mx=ksum[i] + kmax[i].first;

			f = i;
			b= i ;
		}
		//cout << ksum[i] << '\t' << kmax[i].first << endl;
	}
	ll val = kmax[b].first;
	bool flag = 0 ;
	for (int i = 0 ; i < n ; i ++){
		if (ksum[i] == val and f+ k <= i)  {
			b=i;
			flag = 1;
			break;
		}
	}
	if (!flag){
		b=kmax[b].second;
	}
	cout << ++f << '\t' << ++b;

	return(0);
}
//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, l is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
    }
    return res;
}
void trace(int pos, bool ca, bool cb){
    if(ca == false){
        if(f[pos][false][false] == f[pos + 1][false][false]) return trace(pos + 1, false, false);
        cout << pos << " ";
        return trace(pos + 1, true, false);
    }else {
        if(f[pos][true][false] == f[pos + 1][true][false]) return trace(pos + 1, true, false);
        cout << pos;
    }
}
int32_t main(){
    //freopen("text.txt", "r", stdin);
    //freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    trace(1, 0, 0);
}


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]) x = pos;
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]) y = pos;
    }
    return res;
}
int32_t main(){
    freopen("text.txt", "r", stdin);
    freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    cout << x << " " << y;
}


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]) x = pos;
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]) y = pos;
    }
    return res;
}
int32_t main(){
    //freopen("text.txt", "r", stdin);
    //freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    if(x == y) y++;
    cout << x << " " << y;
}


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]) x = pos;
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
        if(res == dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]) y = pos;
    }
    return res;
}
int32_t main(){
    //freopen("text.txt", "r", stdin);
    //freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    cout << x << " " << y;
}


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
    }
    return res;
}
void trace(int pos, bool ca, bool cb){
    if(ca == false){
        if(f[pos][false][false] != dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]) return trace(pos + 1, false, false);
        cout << pos << " ";
        return trace(pos + k, true, false);
    }else {
        if(f[pos][true][false] != dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]) return trace(pos + 1, true, false);
        cout << pos;
    }
}
int32_t main(){
    //freopen("text.txt", "r", stdin);
    //freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    trace(1, 0, 0);
}


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

const int Sz = 2e5 + 5;
int n, k;
int a[Sz];
int pre[Sz];
int f[Sz][2][2];
int x, y;
int dp(int pos, bool ca, bool cb){
    if(pos + 2 * k - 1 > n && ca == false) return -1e15;
    if(pos + k - 1 > n && cb == false) return -1e15;
    if(ca == true && cb == true) return 0;
    int &res = f[pos][ca][cb];
    if(res != -1) return res;
    if(ca == false){
        res = max(dp(pos + 1, false, false), dp(pos + k, true, false) + pre[pos + k - 1] - pre[pos - 1]);
    }else {
        res = max(dp(pos + 1, true, false), dp(pos + k, true, true) + pre[pos + k - 1] - pre[pos - 1]);
    }
    return res;
}
void trace(int pos, bool ca, bool cb){
    if(ca == false){
        if(f[pos][false][false] == f[pos + 1][false][false]) return trace(pos + 1, false, false);
        cout << pos << " ";
        return trace(pos + k, true, false);
    }else {
        if(f[pos][true][false] == f[pos + 1][true][false]) return trace(pos + 1, true, false);
        cout << pos;
    }
}
int32_t main(){
    //freopen("text.txt", "r", stdin);
    //freopen("textout.txt.", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    pre[0] = 0;
    memset(f, -1, sizeof(f));
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }
    dp(1, 0, 0);
    trace(1, 0, 0);
}


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

using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

string to_string(const string & s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(char c) {
    return to_string(string(1, c));
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto & a : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(a);
    }
    res += "}";
    return res;
}

void debug_out() {
    cerr << endl;
}

template<typename A, typename... B>
void debug_out(A a, B... b) {
    cerr << to_string(a);
    if (sizeof...(b)) cerr << ", ";
    debug_out(b...);
}

#ifdef LOCAL
#define debug(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ios_base::sync_with_stdio(0);

    int n, k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<ll> sum(n);

    int csum = 0;
    for (int i = 0; i < k; i++) {
        csum += a[i];
    }

    sum[0] = csum;
    for (int i = k; i < n; i++) {
        csum += a[i];
        csum -= a[i-k];
        sum[i-k+1] = csum;
    }

    vector<pii> suff(n+1);
    suff[n-1] = {n-1, sum[n-1]};
    for (int i = n-2; i >= 0; i--) {
        suff[i] = suff[i+1];
        if (sum[i] >= suff[i].second)
            suff[i] = {i, sum[i]};
    }

    debug(sum);
    debug(suff);

    ll ans = 0, ai = -1, bi = -1;
    for (int i = 0; i < n-k-1; i++) {
        ll cans = sum[i] + suff[i+k].second;
        if (cans > ans) {
            ai = i, bi = suff[i+k].first;
            ans = cans;
        }
    }

    debug(ans);
    cout << ai+1 << " " << bi+1 << '\n';
}