/**
*   author : SheRlocked_221B
*   created : 29/09/2020
*
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) (ll)__builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef int ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/(db)log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str,st;
bool ok = true;
vll v,g,nxt,pre;
vvl tmp;
ll dpo[N],dpp[N];
ll solvep(ll i)
{
    if(i>=m)
    {
        return(m);
    }
    if(dpp[i]!=-1)
    {
        return(dpp[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = nxt[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin();
    if(c!=sz(tmp[b]))
    {
        ll d = tmp[b][c];
        ans = solvep(d);
    }
    dpp[i] = ans;
    return(ans);
}
ll solveo(ll i)
{
    if(i<0)
    {
        return(m);
    }
    if(dpo[i]!=-1)
    {
        return(dpo[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = pre[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin() - 1;
    if(c!=-1)
    {
        ll d = tmp[b][c];
        //ww3(i,d,b);
        ans = solveo(d);
    }
    dpo[i] = ans;
    return(ans);
}
void solveIt()
{
    //NOWECANTBEDEFEATED
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w,u;
    string str1,str2;
    char ch;
    cin>>n>>m>>q;
    for(i=0 ; i<m+2 ; i++)
    {
        dpo[i] = dpp[i] = -1;
    }
    READ(v,n);
    READ(g,m);
    nxt.resz(n+1);
    pre.resz(n+1);
    for(i=0 ; i<n-1;  i++)
    {
        a = v[i];
        b = v[i+1];
        nxt[a] = b;
        pre[b] = a;
    }
    nxt[v.back()] = v.front();
    pre[v.front()] = v.back();
    tmp.resz(n+1);
    for(i=0 ; i<m ; i++)
    {
        a = g[i];
        tmp[a].pb(i);
        if(a==v.back())
        {
            dpp[i] = i;
        }
        if(a==v.front())
        {
            dpo[i] = i;
        }
    }
    //ww1(solveo(2));
    vector<vpll> gmp(n+1);
    for(i=0 ; i<m ; i++)
    {
        solvep(i);
        a = solveo(i);
        if(a==m)
        {
            continue;
        }
        gmp[g[i]].pb({a,i});
    }
    // for(i=0 ; i<m ; i++)
    // {
    //     ws1(dpo[i]);
    // }
    // ww1("");
    // for(i=0 ; i<m ; i++)
    // {
    //     ws1(dpp[i]);
    // }
    // ww1("");
    for(i=0 ; i<n ; i++)
    {
        sort(all(gmp[v[i]]));
    }
    vll ans(m,m);
    for(i=0 ;i<m ; i++)
    {
        a = g[i];
        if(dpp[i]==m)
        {
            //ans[i] = m;
            continue;
        }
        if(a==v.front())
        {
            ans[i] = dpp[i];
            //ww2(i,dpp[i]);
            continue;
        }
        b = nxt[a];
        c = pre[a];
        d = m;
        // for(auto p : tmp[c])
        // {
        //     if(dpo[p]!=m && dpo[p]>dpp[i])
        //     {
        //         d = min(d,p);
        //     }
        // }
        x = lowerB(all(gmp[c]),mkp(dpp[i],0)) - gmp[c].begin();
        if(x!=sz(gmp[c]))
        {
            d = gmp[c][x].se;
        }
        ans[i] = d;
    }
    //PRINT(ans);
    for(i=m-2 ; i>=0 ; i--)
    {
        ans[i] = min(ans[i],ans[i+1]);
    }
    while(q--)
    {
        cin>>a>>b;
        a--;
        b--;
        if(ans[a]<=b)
        {
            cout<<"1";
        }
        else
        {
            cout<<"0";
        }
    }
    ww1("");
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    // const ll ddx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    // const ll ddy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
    /*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
    */
}


/**
*   author : SheRlocked_221B
*   created : 29/09/2020
*
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) (ll)__builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef int ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/(db)log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str,st;
bool ok = true;
vll v,g,nxt,pre;
vvl tmp;
ll dpo[N],dpp[N];
ll solvep(ll i)
{
    if(i>=m)
    {
        return(m);
    }
    if(dpp[i]!=-1)
    {
        return(dpp[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = nxt[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin();
    if(c!=sz(tmp[b]))
    {
        ll d = tmp[b][c];
        ans = solvep(d);
    }
    dpp[i] = ans;
    return(ans);
}
ll solveo(ll i)
{
    if(i<0)
    {
        return(m);
    }
    if(dpo[i]!=-1)
    {
        return(dpo[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = pre[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin() - 1;
    if(c!=-1)
    {
        ll d = tmp[b][c];
        //ww3(i,d,b);
        ans = solveo(d);
    }
    dpo[i] = ans;
    return(ans);
}
void solveIt()
{
    //NOWECANTBEDEFEATED
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w,u;
    string str1,str2;
    char ch;
    cin>>n>>m>>q;
    for(i=0 ; i<m+2 ; i++)
    {
        dpo[i] = dpp[i] = -1;
    }
    READ(v,n);
    READ(g,m);
    nxt.resz(n+1);
    pre.resz(n+1);
    for(i=0 ; i<n-1;  i++)
    {
        a = v[i];
        b = v[i+1];
        nxt[a] = b;
        pre[b] = a;
    }
    nxt[v.back()] = v.front();
    pre[v.front()] = v.back();
    tmp.resz(n+1);
    for(i=0 ; i<m ; i++)
    {
        a = g[i];
        tmp[a].pb(i);
        if(a==v.back())
        {
            dpp[i] = i;
        }
        if(a==v.front())
        {
            dpo[i] = i;
        }
    }
    //ww1(solveo(2));
    vector<vpll> gmp(n+1);
    for(i=0 ; i<m ; i++)
    {
        solvep(i);
        a = solveo(i);
        if(a==m)
        {
            continue;
        }
        gmp[g[i]].pb({a,i});
    }
    for(i=0 ; i<n ; i++)
    {
        sort(all(gmp[v[i]]));
    }
    vll ans(m,m);
    for(i=0 ;i<m ; i++)
    {
        a = g[i];
        if(dpp[i]==m)
        {
            //ans[i] = m;
            continue;
        }
        if(a==v.front())
        {
            ans[i] = dpp[i];
            //ww2(i,dpp[i]);
            continue;
        }
        b = nxt[a];
        c = pre[a];
        d = m;
        // for(auto p : tmp[c])
        // {
        //     if(dpo[p]!=m && dpo[p]>dpp[i])
        //     {
        //         d = min(d,p);
        //     }
        // }
        x = lowerB(all(gmp[c]),mkp(dpp[i],0)) - gmp[c].begin();
        if(x!=sz(gmp[c]))
        {
            d = gmp[c][x].se;
        }
        ans[i] = d;
    }
    //PRINT(ans);
    for(i=m-2 ; i>=0 ; i--)
    {
        ans[i] = min(ans[i],ans[i+1]);
    }
    while(q--)
    {
        cin>>a>>b;
        a--;
        b--;
        if(ans[a]<=b)
        {
            cout<<"1";
        }
        else
        {
            cout<<"0";
        }
    }
    ww1("");
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    // const ll ddx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    // const ll ddy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
    /*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
    */
}


/**
*   author : SheRlocked_221B
*   created : 29/09/2020
*
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define distinct(x) sort(all(x)); x.resize(unique(all(x))-x.begin());
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define resz resize
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 200003  //N idhar hai
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define ms(dp,a) memset(dp,(ll)a,sof(dp))
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define fr(i,b) for(int (i)=(0);(i) < (b); ++(i))
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION(n) std::cout.unsetf ( std::ios::floatfield );std::cout.precision((ll)n)
#define getsm(v) accumulate(all(v),(ll)0)
#define getmx(v) max_element(all(v))
#define getmn(v) min_element(all(v))
#define ws1(a) cout<<(a)<<" "
#define wr1(a) cout<<(a)<<endl
#define wr2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wr3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define wr4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define ww1(a) cout<<(a)<<"\n"
#define ww2(a,b) cout<<(a)<<" "<<(b)<<"\n"
#define ww3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<"\n"
#define ww4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<"\n"
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fill(dp,a,b) for(int i=0;i<a;i++)for(int j=0;j<b;j++)dp[i][j]=-1;
#define PI 3.14159265358979323846264338327950288419716939937510
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define dbg cout<<"Krishna"<<endl
#define showzero cout<<std::showpoint
#define bitcount( x ) (ll)__builtin_popcountll( x )
#define ls(i) (1ll<<(i))
using namespace __gnu_pbds; //required
using namespace  std ;
typedef double db;
typedef int ll ; //long long
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
void READ(vll &v, ll n){ll a ;for(ll i=0 ; i<n ; i=i+1){cin>>a ;v.pb(a);}}
void PRINT(vll &v , ll a = 0){for(ll i=a ; i<v.size() ; i=i+1){/*v[i] = max((ll)0,v[i]);*/cout<<v[i]<<" " ;}cout<<"\n" ;}
double logy(ll n , ll b){if(b==0){return(-1);}if(n==1){return(0);}return((db)log10(n)/(db)log10(b));}
long long power(long long k , long long n , long long m=mod){long long res = 1;while(n){if(n%2!=0){res = (res*k)%m ;}k = (k*k)%m ;n = n/2 ;}return(res) ;}
double powerD(double k , long long n ){double res = 1;while(n){if(n%2!=0){res = (res*k) ;}k = (k*k) ;n = n/2 ;}return(res) ;}
ll gcdExtend(ll a , ll b , ll &x , ll &y){if(a==0){x = 0;y = 1;return(b);}ll x1,y1;ll g = gcdExtend(b%a,a,x1,y1);x = y1 - (b/a)*x1;y = x1;return(g);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
#define lcm(a,b) ((a/gcd(a,b))*b)
void mul(ll &x , ll a){if(a<0){a+=mod;}else{a%=mod;}x = (x%mod*a%mod)%mod;}
double distance(pair<db,db> a , pair<db,db> b){return((db)(sqrt( sqr(a.fi-b.fi) + sqr(a.se-b.se))));}
ll n,m,k,h,a1,a2,a3;
//db prob;
string str,st;
bool ok = true;
vll v,g,nxt,pre;
vvl tmp;
ll dpo[N],dpp[N];
ll solvep(ll i)
{
    if(i>=m)
    {
        return(m);
    }
    if(dpp[i]!=-1)
    {
        return(dpp[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = nxt[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin();
    if(c!=sz(tmp[b]))
    {
        ll d = tmp[b][c];
        ans = solvep(d);
    }
    dpp[i] = ans;
    return(ans);
}
ll solveo(ll i)
{
    if(i<0)
    {
        return(m);
    }
    if(dpo[i]!=-1)
    {
        return(dpo[i]);
    }
    ll ans = m;
    ll a = g[i];
    ll b = pre[a];
    ll c = lowerB(all(tmp[b]),i) - tmp[b].begin() - 1;
    if(c!=-1)
    {
        ll d = tmp[b][c];
        //ww3(i,d,b);
        ans = solveo(d);
    }
    dpo[i] = ans;
    return(ans);
}
void solveIt()
{
    //NOWECANTBEDEFEATED
    ll a,b,c,d,i,j,x,y,z,t;
    ll p,q,r,w,u;
    string str1,str2;
    char ch;
    cin>>n>>m>>q;
    for(i=0 ; i<m+2 ; i++)
    {
        dpo[i] = dpp[i] = -1;
    }
    READ(v,n);
    READ(g,m);
    nxt.resz(n+1);
    pre.resz(n+1);
    for(i=0 ; i<n-1;  i++)
    {
        a = v[i];
        b = v[i+1];
        nxt[a] = b;
        pre[b] = a;
    }
    nxt[v.back()] = v.front();
    pre[v.front()] = v.back();
    tmp.resz(n+1);
    for(i=0 ; i<m ; i++)
    {
        a = g[i];
        tmp[a].pb(i);
        if(a==v.back())
        {
            dpp[i] = i;
        }
        if(a==v.front())
        {
            dpo[i] = i;
        }
    }
    //ww1(solveo(2));
    vector<vpll> gmp(n+1);
    for(i=0 ; i<m ; i++)
    {
        solvep(i);
        a = solveo(i);
        gmp[g[i]].pb({a,i});
    }
    // for(i=0 ; i<m ; i++)
    // {
    //     ws1(dpo[i]);
    // }
    // ww1("");
    // for(i=0 ; i<m ; i++)
    // {
    //     ws1(dpp[i]);
    // }
    // ww1("");
    for(i=0 ; i<n ; i++)
    {
        sort(all(gmp[g[i]]));
    }
    vll ans(m,m);
    for(i=0 ;i<m ; i++)
    {
        a = g[i];
        if(dpp[i]==m)
        {
            //ans[i] = m;
            continue;
        }
        if(a==v.front())
        {
            ans[i] = dpp[i];
            //ww2(i,dpp[i]);
            continue;
        }
        b = nxt[a];
        c = pre[a];
        d = m;
        // for(auto p : tmp[c])
        // {
        //     if(dpo[p]!=m && dpo[p]>dpp[i])
        //     {
        //         d = min(d,p);
        //     }
        // }
        x = lowerB(all(gmp[c]),mkp(dpp[i],0)) - gmp[c].begin();
        if(x!=sz(gmp[c]))
        {
            d = gmp[c][x].se;
        }
        ans[i] = d;
    }
    //PRINT(ans);
    for(i=m-2 ; i>=0 ; i--)
    {
        ans[i] = min(ans[i],ans[i+1]);
    }
    while(q--)
    {
        cin>>a>>b;
        a--;
        b--;
        if(ans[a]<=b)
        {
            cout<<"1";
        }
        else
        {
            cout<<"0";
        }
    }
    ww1("");
}
int main()
{
#ifndef ONLINE_JUDGE
        freopen("Rinput.txt", "r", stdin);
        freopen("Routput.txt", "w", stdout);
#endif
    FastIO;
    PRECISION(15);
    //FileIO;
    //dr.pb(mkp(0,1));dr.pb(mkp(1,0));dr.pb(mkp(0,-1));dr.pb(mkp(-1,0));
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solveIt();
    }
    // const ll ddx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    // const ll ddy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    //WhateverItTakes
    //FOCUS
    //BeABelieverWarrior
    //DO IT UNTIL YOU RUN OUT OF IDEAS ~ YOU KNOW WHO
    //See The Editorial Almost Never ~ YOU KNOW WHO
    /*In Case of TLE -> 1.Use Int instead of Long Long
                    2.Use FastIO
                    3.Use "\n" Instead of endl
                    4.Use Vector and Arrays instead of Sets,Maps(if possible)
    */
}


#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005;
int n,m,q,p[Maxn],nex[Maxn][22],a[Maxn],nxt[Maxn],las[Maxn],mini[Maxn][22],bel[Maxn],cnt;
queue <int> Qu[Maxn];
int ask(int l,int r)
{
	int siz=log2(r-l+1);
	return min(mini[l][siz],mini[r-(1<<siz)+1][siz]);
}
int main()
{
	freopen("E.in","r",stdin);
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		nxt[p[i]]=p[i%n+1];
	for(int i=m;i>=1;i--)
	{
		nex[i][0]=las[nxt[a[i]]];
		las[a[i]]=i;
	}
	for(int i=1;i<=m;i++)
		if(!nex[i][0]) nex[i][0]=m+1;
	for(int i=1;(1<<i)<=m;i++)
		for(int j=1;j<=m;j++)
			nex[j][i]=nex[j][i-1]>m?m+1:nex[nex[j][i-1]][i-1];
	for(int i=1;i<=m;i++)
	{
		mini[i][0]=i;
		for(int j=21;j>=0;j--)
			if((n-1)&(1<<j)) mini[i][0]=nex[mini[i][0]][j];
	}
	for(int i=1;(1<<i)<=m;i++)
		for(int j=1;j<=m;j++)
			mini[j][i]=min(mini[j][i-1],mini[j+(1<<(i-1))][i-1]);
	for(int i=1;i<=q;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d",ask(l,r)<=r);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005;
int n,m,q,p[Maxn],nex[Maxn][22],a[Maxn],nxt[Maxn],las[Maxn],mini[Maxn][22],bel[Maxn],cnt;
queue <int> Qu[Maxn];
int ask(int l,int r)
{
	int siz=log2(r-l+1);
	return min(mini[l][siz],mini[r-(1<<siz)+1][siz]);
}
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		nxt[p[i]]=p[i%n+1];
	for(int i=m;i>=1;i--)
	{
		nex[i][0]=las[nxt[a[i]]];
		las[a[i]]=i;
	}
	for(int i=1;i<=m;i++)
		if(!nex[i][0]) nex[i][0]=m+1;
	for(int i=1;(1<<i)<=m;i++)
		for(int j=1;j<=m;j++)
			nex[j][i]=nex[j][i-1]>m?m+1:nex[nex[j][i-1]][i-1];
	for(int i=1;i<=m;i++)
	{
		mini[i][0]=i;
		for(int j=21;j>=0;j--)
			if((n-1)&(1<<j))
			{
				mini[i][0]=nex[mini[i][0]][j];
				if(mini[i][0]==m+1) break;
			}
	}
	for(int i=1;(1<<i)<=m;i++)
		for(int j=1;j<=m;j++)
			mini[j][i]=min(mini[j][i-1],mini[j+(1<<(i-1))][i-1]);
	for(int i=1;i<=q;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d",ask(l,r)<=r);
	}
	return 0;
}


import java.util.*;
public class Uyi{
    public static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {
        int t = s.nextInt();
        for (int id = 0; id < t; id++) {
            int n = s.nextInt();
            int k = s.nextInt();
            int [] a = new int [n + 1];
            for (int j = 1; j <= n; j++) {
                a[j] = s.nextInt();
            }
            a[0] = Integer.MAX_VALUE;
            boolean []ispike = new boolean[n + 1];
            for (int i = 1; i <= n; i++) {
                if (i != n){
                    if (a[i] > a[i-1] && a[i] > a[i+1]) ispike[i] = true;
                }
            }
            int l = 1;
            int r = k;
            int debc = 0;
            for (int i = 2; i <= k - 1; i++) {
                if (ispike[i]) debc++;
            }
            int maxpikes = debc;
            int index = 1;
            for (int i = 2; i <= n - k + 1; i++) {
                int c = debc;
                if (ispike[i-1]) c--;
                if (ispike[i + k - 2]) c++;
                if (c > maxpikes) {
                    maxpikes = c;
                    index = i;
                }
                debc = c;
            }
            System.out.println((maxpikes + 1) + " " + index);
        }
    }
    static boolean isp(int l1, int r1, int l2, int r2){
        if (r2 < l1 || r1 < l2) return false;
        return true;
    }
}


import java.util.*;
public class Uyi{
    public static Scanner s = new Scanner(System.in);
    public static void main(String[] args) {
        int t = s.nextInt();
        for (int id = 0; id < t; id++) {
            int n = s.nextInt();
            int k = s.nextInt();
            int [] a = new int [n + 1];
            for (int j = 1; j <= n; j++) {
                a[j] = s.nextInt();
            }
            a[0] = Integer.MAX_VALUE;
            boolean []ispike = new boolean[n + 1];
            for (int i = 2; i <= n; i++) {
                if (i != n){
                    if (a[i] > a[i-1] && a[i] > a[i+1]) ispike[i] = true;
                }
            }
            int l = 1;
            int r = k;
            int debc = 0;
            for (int i = 2; i <= k - 1; i++) {
                if (ispike[i]) debc++;
            }
            int maxpikes = debc;
            int index = 1;
            for (int i = 2; i <= n - k + 1; i++) {
                int c = debc;
                if (ispike[i]) c--;
                if (ispike[i + k - 2]) c++;
                if (c > maxpikes) {
                    maxpikes = c;
                    index = i;
                }
                debc = c;
            }
            maxpikes++;
            System.out.println(maxpikes + " " + index);
        }
    }
    static boolean isp(int l1, int r1, int l2, int r2){
        if (r2 < l1 || r1 < l2) return false;
        return true;
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}

				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-') {
				sgn = -1;
				c = read();
			}

			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return readString();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception {
		new Thread(null, new Solution(), "Main", 1 << 27).start();
	}

	static class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x * 7 + (y * 3 + 5 * (y - x));
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			Pair other = (Pair) obj;
			if (x != other.x && y != other.y) {
				return false;
			}
			return true;
		}
	}

	static void sieveOfEratosthenes(int n) {
		//Prints prime nos till n
		boolean prime[] = new boolean[n + 1];
		for (int i = 0; i <= n; i++)
			prime[i] = true;

		for (int p = 2; p * p <= n; p++) {
			if (prime[p] == true) {
				for (int i = p * p; i <= n; i += p)
					prime[i] = false;
			}
		}

		for (int i = 2; i <= n; i++) {
			if (prime[i] == true)
				System.out.print(i + " ");
		}
	}

	public void run() {
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int arr[]=new int[n];
			boolean peak[]=new boolean[n];
			for(int i=0;i<n;i++)
				arr[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(arr[i]>arr[i-1] && arr[i]>arr[i+1])
					peak[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=1;i<n;i++)
			{
				if(i==k)
					f=true;
				if(f)
				{
					j++;
					if(peak[j])
						count--;
				}
				if(peak[i-1])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			w.println((max+1)+" "+(ind+1));
		}
		w.flush();
		w.close();
	}
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	static class InputReader {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();

			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}

				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		public int nextInt() {
			int c = read();

			while (isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-') {
				sgn = -1;
				c = read();
			}

			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public double nextDouble() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') {
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') {
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) {
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next() {
			return readString();
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception {
		new Thread(null, new Solution(), "Main", 1 << 27).start();
	}

	static class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + x * 7 + (y * 3 + 5 * (y - x));
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			Pair other = (Pair) obj;
			if (x != other.x && y != other.y) {
				return false;
			}
			return true;
		}
	}

	static void sieveOfEratosthenes(int n) {
		//Prints prime nos till n
		boolean prime[] = new boolean[n + 1];
		for (int i = 0; i <= n; i++)
			prime[i] = true;

		for (int p = 2; p * p <= n; p++) {
			if (prime[p] == true) {
				for (int i = p * p; i <= n; i += p)
					prime[i] = false;
			}
		}

		for (int i = 2; i <= n; i++) {
			if (prime[i] == true)
				System.out.print(i + " ");
		}
	}

	public void run() {
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int a[]=new int[n];
			boolean p[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(a[i]>a[i-1] && a[i]>a[i+1])
					p[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=0;i<n;i++)
			{
				if(i==k-1)
					f=true;
				if(f)
				{
					if(p[j])
						count--;
					j++;
				}
				if(p[i])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			w.println((max+1)+" "+(ind+1));
		}
		w.flush();
		w.close();
	}
}


import java.util.*;

public class file {

    private static final Scanner scn = new Scanner(System.in);
    private static int cas;

    private static void foo() {
        int n = scn.nextInt();
        int k = scn.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scn.nextInt();
        }
        int leftMax = -1;
        int max = -1000000000;
        int[] arr = new int[n];
        ArrayList<Integer> lis = new ArrayList<>();
        for (int i = 1; i < n-1; i++) {
            arr[i] = arr[i-1];
            if (a[i-1] < a[i] && a[i] > a[i+1]) {
                arr[i]++;
            }
        }
        arr[n-1] = arr[n-2];
        for (int i = 0, x; i <= n - k; i++) {
            x = arr[i+k-2]-arr[i];
            if (x > max) {
                max = x;
                leftMax = i;
            }
        }
        max++;
        leftMax++;

        System.out.printf("%d %d\n", max, leftMax);

    }

    public static void main(String[] args) {
        cas = scn.nextInt();
        for (int i = 1; i <= cas; i++) foo();
    }
}


import java.util.*;
public class NastyaAndDoor
{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t!=0)
        {
            int n=sc.nextInt();
            int k=sc.nextInt();
            int arr[]=new int[n];
            for(int i=0;i<n;i++)
                arr[i]=sc.nextInt();

            int peak[]=new int[n];
            peak[0]=0;
            for(int i=1;i<n;i++)
            {
                if(i<n-1)
                {
                    if(i+1<n && arr[i]>arr[i-1] && arr[i]>arr[i+1])
                        peak[i]=peak[i-1]+1;
                    else
                        peak[i]=peak[i-1];
                }
            }
            int currl=0;
            int max=0;
            // for(int i=0;i<n;i++)
            //     System.out.print(peak[i]+" ");
            // System.out.println();
            for(int i=0;i<=n-k;i++)
            {
                int count=peak[i+k-2]-peak[i];
                if(count>max)
                {
                    max=count;
                    currl=i+1;
                    // System.out.println(max+" "+currl);
                }
            }
            System.out.println((max+1)+" "+(currl));
            t--;
        }
    }
}


import java.util.*;
public class NastyaAndDoor
{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t!=0)
        {
            int n=sc.nextInt();
            int k=sc.nextInt();
            int arr[]=new int[n];
            for(int i=0;i<n;i++)
                arr[i]=sc.nextInt();

            int peak[]=new int[n];
            peak[0]=0;
            for(int i=1;i<n;i++)
            {
                if(i<n-1)
                {
                    if(i+1<n && arr[i]>arr[i-1] && arr[i]>arr[i+1])
                        peak[i]=peak[i-1]+1;
                    else
                        peak[i]=peak[i-1];
                }
            }
            int currl=0;
            int max=0;
            // for(int i=0;i<n;i++)
            //     System.out.print(peak[i]+" ");
            // System.out.println();
            for(int i=0;i<=n-k;i++)
            {
                int count=peak[i+k-2]-peak[i];
                if(count>max)
                {
                    max=count;
                    currl=i+1;
                    // System.out.println(max+" "+currl);
                }
            }
            System.out.println((max+1)+" "+Math.max(1,(currl)));
            t--;
        }
    }
}


import java.util.*;
import java.io.*;

public class Main {
	static final long M = 1000000007;
		static FastReader in = new FastReader();
		static PrintWriter out = new PrintWriter(System.out);
//		static Scanner in = new Scanner(System.in);
//        File file = new File("input.txt");
//        Scanner in = new Scanner(file);
//        PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
    public static void main(String[] args) {

    	int t = in.nextInt();
    	while(t-- > 0) {
    		int n = in.nextInt(), k = in.nextInt();
    		int[] mount = new int[n+2];
    		for(int i = 1; i<=n; i++) mount[i] = in.nextInt();
    		int max_peak = 0, max_index = 1;
    		for(int i = 2; i<k; i++) {
    			if(mount[i]>mount[i-1] && mount[i]>mount[i+1]) {
    				max_peak++;
    			}
    		}
    		int last_peak = max_peak;
    		for(int i = k+1; i<=n; i++) {
    			int p = last_peak;
    			if(mount[i-k+1]>mount[i-k] && mount[i-k+1]>mount[i-k+2]) {
    				p--;
    			}
    			if(mount[i-1] > mount[i-2] && mount[i-1] > mount[i]) {
    				p++;
    			}
    			if(p>max_peak) {
    				max_peak = p;
    				max_index = i-k+1;
    			}
    			last_peak = p;
    		}
    		out.println((max_peak+1)+" "+max_index);

    	}

    	out.close();
    }

    private static int gcd(int a, int b) {
    	if(b==0) return a;
    	return gcd(b, a%b);
    }

	static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    static Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static void main(String[] args) {
        problem(scanner.nextInt());

    }

    public static void problem(int t) {
        int n, length, maxPeaks, peaks, firstIndex;
        int[] arr, arr2;
        for (int i=0; i<t; i++){
            n = scanner.nextInt();
            length = scanner.nextInt();
            arr = new int[n];
            arr2 = new int[n];
            firstIndex =1;

            arr[0] = scanner.nextInt();
            arr[1] = scanner.nextInt();
            for (int j=2; j<arr.length; j++){
                arr[j] =scanner.nextInt();
                if (arr[j] < arr[j-1] && arr[j-1]>arr[j-2]) {
                    arr2[j-1] =1;
                }
            }

            maxPeaks =0;
            for (int j=1; j<length-1; j++){
                if (arr2[j] ==1 && arr2[j+1] ==0 &&arr2[j-1] ==0 )
                    maxPeaks ++;
            }
            peaks = maxPeaks;
            for (int j=length; j<arr2.length; j++){
                if (arr2[j] ==0 && arr2[j-1] ==1 && arr2[j-length+1] !=1)
                    peaks ++;
                else if (arr2[j-1] ==0 && arr2[j-length+1] ==1)
                    peaks --;
                if (peaks>maxPeaks) {
                    maxPeaks = peaks;
                    firstIndex = j-length+2;
                }
            }
            System.out.println((maxPeaks+1) + " " + (firstIndex));
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    static Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static void main(String[] args) {
        problem(scanner.nextInt());

    }

    public static void problem(int t) {
        int n, length, maxPeaks, peaks, firstIndex;
        int[] arr, arr2;
        for (int i=0; i<t; i++){
            n = scanner.nextInt();
            length = scanner.nextInt();
            arr = new int[n];
            arr2 = new int[n];
            maxPeaks =0;
            firstIndex =1;

            arr[0] = scanner.nextInt();
            arr[1] = scanner.nextInt();
            for (int j=2; j<arr.length; j++){
                arr[j] =scanner.nextInt();
                if (arr[j] < arr[j-1] && arr[j-1]>arr[j-2]) {
                    arr2[j-1] =1;
                }
            }

            maxPeaks =0;
            for (int j=0; j<arr2.length-length+1; j++){
                peaks =0;
                for (int k=j+1; k< j+length-1; k++){
                    if (arr2[k]==1 && arr2[k+1]==0 && arr2[k-1]==0)
                        peaks ++;
                }
                if (peaks > maxPeaks){
                    firstIndex =j+1;
                    maxPeaks = peaks;
                }
            }
            System.out.println((maxPeaks+1) + " " + (firstIndex));
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    static Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static void main(String[] args) {
        problem(scanner.nextInt());

    }

    public static void problem(int t) {
        int n, length, maxPeaks, peaks, firstIndex;
        int[] arr, arr2;
        for (int i=0; i<t; i++){
            n = scanner.nextInt();
            length = scanner.nextInt();
            arr = new int[n];
            arr2 = new int[n];
            maxPeaks =0;
            firstIndex =n;
            for (int j=0; j<arr.length; j++){
                arr[j] =scanner.nextInt();
                if (j >=2 &&arr[j] < arr[j-1] && arr[j-1]>arr[j-2]) {
                    arr2[j-1] =1;
                }
            }
            maxPeaks =0;
            for (int j=0; j<arr2.length-length+1; j++){
                peaks =0;
                for (int k=j+1; k< j+length-1; k++){
                    if (arr2[k]==1 && arr2[k+1]==0 && arr2[k-1]==0)
                        peaks ++;
                }
                if (peaks > maxPeaks){
                    firstIndex =j+1;
                    maxPeaks = peaks;
                }
            }
            System.out.println((maxPeaks+1) + " " + (firstIndex));
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int t = sc.nextInt();
	int n, k;

	for(int u = 0; u<t; u++) {
		n = sc.nextInt();
		k = sc.nextInt();
		int a[] = new int[n];
		int apr[] = new int[n];
		a[0] = sc.nextInt();
		apr[0] = 0;
		for(int i = 1; i<n; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 1; i<n-1; i++){
			if(a[i-1]<a[i]&&a[i+1]<a[i])
				apr[i+1]=1+apr[i];
			else
				apr[i+1]=apr[i];
		}
		int max = -1000000000;
		int maxind = -1;
		for(int i = 0, x; i<=n-k; i++){
			x = apr[i+k-1]-apr[i];
			if(x>max){
				max = x;
				maxind = i;
			}
		}
		max+=1;
		maxind+=1;
		System.out.println(max+" "+maxind);

	}
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int t = sc.nextInt();
	int n, k;

	for(int u = 0; u<t; u++) {
		n = sc.nextInt();
		k = sc.nextInt();
		int a[] = new int[n];
		int apr[] = new int[n];
		a[0] = sc.nextInt();
		apr[0] = 0;
		for(int i = 1; i<n; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 1; i<n-1; i++){
			apr[i]=apr[i-1];
			if(a[i-1]<a[i]&&a[i+1]<a[i])
				apr[i]++;
		}
		apr[n-1]=apr[n-2];
		int max = -1000000000;
		int maxind = -1;
		for(int i = 0, x; i<=n-k; i++){
			x = apr[i+k-2]-apr[i];
			if(x>max){
				max = x;
				maxind = i;
			}
		}
		max+=1;
		maxind+=1;
		System.out.println(max+" "+maxind);

	}
    }
}


import java.util.*;
import java.io.*;

public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] a = new int[n];
			int[] peaks = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			for(int i = 1; i < n - 1; i++) {
				if(a[i] > a[i-1] && a[i] > a[i+1]) {
					peaks[i] = 1;
				} else {
					peaks[i] = 0;
				}
			}
			int count = 0;
			for(int i = 1; i < k - 1; i++) {
				count += peaks[i];
			}

			int ans = count;
			int l = 0;
			for(int i = k; i < n; i++) {
				count += peaks[i-1] - peaks[i-k+1];
				if(count > ans) {
					ans = count;
					l = i - k +1;
				}
			}
			System.out.println((ans + 1) + " " + (l + 1));
		}
	}
}


import java.util.*;
import java.io.*;

public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] a = new int[n];
			int[] peak = new int[n];
			int[] pref = new int[n];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for(int i = 1; i < n - 1; i++) {
				if(a[i] > a[i-1] && a[i] > a[i+1]) {
					peak[i] = 1;
				} else {
					peak[i] = 0;
				}
			}

			for(int i = 1; i < n; i++) {
				pref[i] = pref[i-1] + peak[i-1];
			}
			int maxind = 0;
			for(int i = 0; i < n - k + 1; i++) {
				if(pref[i + k - 1] - pref[i] > pref[maxind + k - 1] - pref[maxind]) {
					maxind = i;
				}
			}
			System.out.println((pref[maxind+k-1] - pref[maxind] + 1) + " " + (maxind+1));
		}
	}
}


import java.util.*;
import java.io.*;

public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			int k = sc.nextInt();
			int[] a = new int[21000];
			int[] peak = new int[21000];
			int[] pref = new int[21000];
			for(int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for(int i = 1; i < n - 1; i++) {
				if(a[i] > a[i-1] && a[i] > a[i+1]) {
					peak[i] = 1;
				} else {
					peak[i] = 0;
				}
			}

			for(int i = 1; i <= n; i++) {
				pref[i] = pref[i-1] + peak[i-1];
			}
			int maxind = 0;
			for(int i = 0; i < n - k + 1; i++) {
				if(pref[i + k - 1] - pref[i + 1] > pref[maxind + k - 1] - pref[maxind + 1]) {
					maxind = i;
				}
			}
			System.out.println((pref[maxind+k-1] - pref[maxind] + 1) + " " + (maxind+1));
		}
	}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class GFG {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner in =new Scanner(System.in);
        int t=in.nextInt();
        while(t-->0){
            int n=in.nextInt(),k=in.nextInt();
            int arr[]=new int[n+1];
            for(int i=1;i<=n;i++)
            arr[i]=in.nextInt();
            int []dp=new int[n+1];
            for(int i=2;i<=n-1;i++)
            {
                if(arr[i]>arr[i-1]&&arr[i]>arr[i+1])
                dp[i]=1;
            }

            int l=1,r=l+k-1;
            int c=0;
            for(int i=l+1;i<r;i++)
            {
            if(dp[i]==1)
            c++;
            }
            int lmax=l,cmax=c;
            // c=0;

            while(r<n)
            {
                if(dp[l+1]==1)
                c--;
                if(dp[r]==1)
                c++;
                l++;
                r++;
                if(c>cmax)
                {
                    cmax=c;
                    lmax=l;
                }

            }
            if(cmax!=0)
            cmax++;
            System.out.println(cmax+" "+lmax);

        }
	}
}


/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class GFG {
	public static void main (String[] args) {
// 		System.out.println("GfG!");
        Scanner in =new Scanner(System.in);
        int t=in.nextInt();
        while(t-->0){
            int n=in.nextInt(),k=in.nextInt();
            int arr[]=new int[n];
            for(int i=0;i<n;i++)
            arr[i]=in.nextInt();
            int []dp=new int[n];
            for(int i=1;i<n-1;i++)
            {
                if(arr[i]>arr[i-1]&&arr[i]>arr[i+1])
                dp[i]=1;
            }
            int l=0,r=1;
            int c=0;
           while(r<k-1)
            {
            if(dp[r]==1)
            c++;
            r++;
            }
            int lmax=l,cmax=c;
            while(r<n-1)
            {
                l++;
                if(dp[l]==1)
                c--;
                if(dp[r]==1)
                c++;

                r++;
                if(c>cmax)
                {
                    cmax=c;
                    lmax=l;
                }

            }
            cmax++;
            lmax++;
            System.out.println(cmax+" "+lmax);

        }
	}
}


import java.util.*;
public class s2 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        while(t-->0){
            int n = s.nextInt();
            int k = s.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++){
                arr[i] = s.nextInt();
            }
            int freq[] = new int[n];
            for(int i=1;i<n-1;i++){
                if(arr[i]>arr[i+1]&&arr[i]>arr[i-1]){
                    freq[i] = 1;
                }
            }
            // for(int i=0;i<n;i++){
            //     System.out.print(freq[i]+" ");
            // }
            // System.out.println("***");
            int cum[] = new int[n];
            int count = 0;
            for(int i=1;i<n;i++){
                if(freq[i-1]==1){
                    count++;
                }
                cum[i]=count;
            }
            // for(int i=0;i<n;i++){
            //     System.out.print(cum[i]+" ");
            // }
            // System.out.println("***");
            int l = -1;
            int peaks = -1;
            for(int i=k-1;i<n;i++){
                int temp  = cum[i]-cum[i-k+1];
                if(temp>peaks){
                    peaks = temp;
                    l = i-k+1;
                }
            }
            System.out.println((peaks+1)+" "+(l+1));
        }
    }
}


import java.util.*;
public class s2 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        while(t-->0){
            int n = s.nextInt();
            int k = s.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++){
                arr[i] = s.nextInt();
            }
            int freq[] = new int[n];
            for(int i=1;i<n-1;i++){
                if(arr[i]>arr[i+1]&&arr[i]>arr[i-1]){
                    freq[i] = 1;
                }
            }
            long cum[] = new long[n];
            for(int i=1;i<n;i++){
                cum[i]=cum[i-1]+freq[i];
            }
            int l = 0;
            long peaks = 0;
            for(int i=0;i<n-k+1;i++){
                long temp  = cum[i+k-2]-cum[i];
                if(temp>peaks){
                    peaks = temp;
                    l = i;
                }
            }
            System.out.println((peaks+1)+" "+(l+1));
        }
    }
}


import java.util.*;
public class s2 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        while(t-->0){
            int n = s.nextInt();
            int k = s.nextInt();
            int arr[] = new int[n];
            for(int i=0;i<n;i++){
                arr[i] = s.nextInt();
            }
            int freq[] = new int[n];
            for(int i=1;i<n-1;i++){
                if(arr[i]>arr[i+1]&&arr[i]>arr[i-1]){
                    freq[i] = 1;
                }
            }
            // for(int i=0;i<n;i++){
            //     System.out.print(freq[i]+" ");
            // }
            // System.out.println("***");
            long cum[] = new long[n];
            long count = 0;
            for(int i=1;i<n;i++){
                if(freq[i-1]==1){
                    count++;
                }
                cum[i]=count;
            }
            // for(int i=0;i<n;i++){
            //     System.out.print(cum[i]+" ");
            // }
            // System.out.println("***");
            int l = 0;
            long peaks = 0;
            for(int i=k-1;i<n;i++){
                long temp  = cum[i]-cum[i-k+1];
                if(temp>peaks){
                    peaks = temp;
                    l = i-k+1;
                }
            }
            // if(peaks==0){
            //     System.out.println((peaks+1)+" "+(l));
            // }else
            System.out.println((peaks+1)+" "+(l+1));
        }
    }
}


import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String args[]) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(br.readLine());
        while(t-->0)
        {
            String s1[] = br.readLine().trim().split(" ");
            int n = Integer.parseInt(s1[0]);
            int k = Integer.parseInt(s1[1]);
            int a[] = new int[n];
            int max = 0, l =0;
            String s2[] = br.readLine().trim().split(" ");
            for(int i = 0; i < n; i++)
                a[i] = Integer.parseInt(s2[i]);
            PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
            for(int i = 1; i < k-1; i++)
                if(a[i] > a[i-1] && a[i] > a[i+1])
                    pq.add(i);
            max = pq.size();
            for(int i = k-1, j = 0; i < n-1; i++, j++)
            {
                if((!pq.isEmpty()) && pq.peek() == j)
                    pq.remove();
                if(a[i] > a[i-1] && a[i] > a[i+1])
                {
                    pq.add(i);
                    if(max < pq.size())
                    {
                        max = pq.size();
                        l = j+1;
                    }
                }
            }
            bw.write(max+1+" "+(l+1)+"\n");
        }
        bw.flush();
    }
}


import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String args[]) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = Integer.parseInt(br.readLine());
        while(t-->0)
        {
            String s1[] = br.readLine().trim().split(" ");
            int n = Integer.parseInt(s1[0]);
            int k = Integer.parseInt(s1[1]);
            int a[] = new int[n];
            int max = 0, l =0;
            String s2[] = br.readLine().trim().split(" ");
            for(int i = 0; i < n; i++)
                a[i] = Integer.parseInt(s2[i]);
            PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
            for(int i = 1; i < k-1; i++)
                if(a[i] > a[i-1] && a[i] > a[i+1])
                    pq.add(i);
            max = pq.size();
            for(int i = k-1, j = 1; i < n-1; i++, j++)
            {
                if((!pq.isEmpty()) && pq.peek() == j)
                    pq.remove();
                if(a[i] > a[i-1] && a[i] > a[i+1])
                {
                    pq.add(i);
                    if(max < pq.size())
                    {
                        max = pq.size();
                        l = j;
                    }
                }
            }
            bw.write(max+1+" "+(l+1)+"\n");
        }
        bw.flush();
    }
}


import java.io.*;
import java.util.*;
public class Main {

	static class PairComparator implements Comparator<Pair> {
		@Override
		public int compare(Pair x, Pair y) {
			if (x.val < y.val)return -1;
			if (x.val > y.val)return 1;
			if (x.val == y.val){
				if (x.ind < y.ind)return -1;
				if (x.ind > y.ind)return 1;
			}
			return 0;
		}
	}
/*

1 1 1 0 1 1
  1 1 0 0 1
  0 1 0 0 0

*/

    static class Pair{
        int ind, val;
        Pair(int i, int v){
            ind=i;
            val=v;
        }
    }
	static int[] vis;
   static void func() throws Exception {
	   int n,k;
	   n = sc.nextInt();
	   k = sc.nextInt();
	   k-=2;
	   int[] arr = sc.intArr(n);
	   int[] p =new int[n];
	   for (int i=1;i<n-1;i++){
		   if (arr[i]>arr[i-1] && arr[i]>arr[i+1])p[i]=1;
	   }
	   int peaks =0;
	   for (int i=1;i<=k;i++){
		   int ind = n-1-i;
		   if (p[ind]==1)peaks++;
	   }
	   int l=n-k-1;
	   int max=peaks;
	   for (int i=n-2-k;i>=1;i--){
		   if (p[i]==1){
			   peaks++;
		   }
		   if (p[i+k]==1)peaks--;
		   if (peaks>=max){
			   max=peaks;
			   l=i;
		   }
	   }
	   pw.println((max+1) + " "  + (l));

   }

/*

 * */
    static PrintWriter pw;
    static MScanner sc;

    public static void main(String[] args) throws Exception {

        pw = new PrintWriter(System.out);
        sc = new MScanner(System.in);

        int tests = 1;
       tests =sc.nextInt(); //comment this line
        while (tests-- > 0){
            func();
            pw.flush();
        }

    }

    static class MScanner {
        StringTokenizer st;
        BufferedReader br;

        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int[] intArr(int n) throws IOException {
            int[] in = new int[n];
            for (int i = 0; i < n; i++)
                in[i] = nextInt();
            return in;
        }

        public long[] longArr(int n) throws IOException {
            long[] in = new long[n];
            for (int i = 0; i < n; i++)
                in[i] = nextLong();
            return in;
        }

        public int[] intSortedArr(int n) throws IOException {
            int[] in = new int[n];
            for (int i = 0; i < n; i++)
                in[i] = nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }

        public long[] longSortedArr(int n) throws IOException {
            long[] in = new long[n];
            for (int i = 0; i < n; i++)
                in[i] = nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }

        public Integer[] IntegerArr(int n) throws IOException {
            Integer[] in = new Integer[n];
            for (int i = 0; i < n; i++)
                in[i] = nextInt();
            return in;
        }

        public Long[] LongArr(int n) throws IOException {
            Long[] in = new Long[n];
            for (int i = 0; i < n; i++)
                in[i] = nextLong();
            return in;
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
    }

    static void shuffle(int[] in) {
        for (int i = 0; i < in.length; i++) {
            int idx = (int) (Math.random() * (i+1));
            int tmp = in[i];
            in[i] = in[idx];
            in[idx] = tmp;
        }
    }

    static void shuffle(long[] in) {
        for (int i = 0; i < in.length; i++) {
            int idx = (int) (Math.random() * (i+1));
            long tmp = in[i];
            in[i] = in[idx];
            in[idx] = tmp;
        }
    }
}


import java.util.Scanner;
public class grains{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while(t-->0){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n+1];
            for(int i=1;i<n+1;i++)
                a[i] = sc.nextInt();
            int[] p = new int[n+1];
            p[0]=0;
            p[1]=0;
            p[2]=0;
            for(int i=2;i<n;i++){
                if(a[i]>a[i-1]&&a[i]>a[i+1])
                    p[i+1] = p[i]+1;
                else{
                p[i+1]=p[i];
                }
            }

            int maxPeaks = 0;
            // for(int i=0;i<p.length;i++)
            // System.out.print(p[i]+" ");
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                if(peaks>maxPeaks){
                    maxPeaks = peaks;
                }
            }
            if(maxPeaks==0)
            System.out.println("0 1");
            else{
            int ans = 0;
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                if(peaks==maxPeaks){
                    ans = i;
                    break;
                }
            }
            System.out.println(maxPeaks+1+" "+ans);
            }
        }
    }
}


import java.util.Scanner;
public class grains{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while(t-->0){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n+1];
            for(int i=1;i<n+1;i++)
                a[i] = sc.nextInt();
            int[] p = new int[n+1];
            p[0]=0;
            p[1]=0;
            boolean isPeak[] = new boolean[n+1];
            for(int i=2;i<n+1;i++){
                if(i!=n&&a[i]>a[i-1]&&a[i]>a[i+1]){
                    p[i] = p[i-1]+1;
                    isPeak[i] = true;
                }
                else{
                p[i]=p[i-1];
                }
            }

            int maxPeaks = 0;
            // for(int i=0;i<p.length;i++)
            // System.out.print(p[i]+" ");
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                int cut1 = (isPeak[i+k-1])?1:0;
                int cut2 = (isPeak[i])?1:0;
                peaks = peaks-cut1-cut2;
                if(peaks>maxPeaks){
                    maxPeaks = peaks;
                }
            }

            int ans = 0;
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                int cut1 = (isPeak[i+k-1])?1:0;
                int cut2 = (isPeak[i])?1:0;
                peaks = peaks-cut1-cut2;
                if(peaks==maxPeaks){
                    ans = i;
                    break;
                }
            }
            System.out.println(maxPeaks+1+" "+ans);

        }
    }
}


import java.util.Scanner;
public class grains{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while(t-->0){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n+1];
            for(int i=1;i<n+1;i++)
                a[i] = sc.nextInt();
            int[] p = new int[n+1];
            p[0]=0;
            p[1]=0;
            p[2]=0;
            for(int i=2;i<n;i++){
                if(a[i]>a[i-1]&&a[i]>a[i+1])
                    p[i+1] = p[i]+1;
                else{
                p[i+1]=p[i];
                }
            }

            int maxPeaks = Integer.MIN_VALUE;
            // for(int i=0;i<p.length;i++)
            // System.out.print(p[i]+" ");
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                if(peaks>maxPeaks){
                    maxPeaks = peaks;
                }
            }
            int ans = 0;
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                if(peaks==maxPeaks){
                    ans = i;
                    break;
                }
            }
            System.out.println(maxPeaks+1+" "+ans);
        }
    }
}


import java.util.Scanner;
public class grains{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while(t-->0){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] a = new int[n+1];
            for(int i=1;i<n+1;i++)
                a[i] = sc.nextInt();
            int[] p = new int[n+1];
            p[0]=0;
            p[1]=0;
            boolean isPeak[] = new boolean[n+1];
            for(int i=2;i<n+1;i++){
                if(i!=n&&a[i]>a[i-1]&&a[i]>a[i+1]){
                    p[i] = p[i-1]+1;
                    isPeak[i] = true;
                }
                else{
                p[i]=p[i-1];
                }
            }

            int maxPeaks = 0;
            // for(int i=0;i<p.length;i++)
            // System.out.print(p[i]+" ");
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                int cut1 = (isPeak[i+k-1])?1:0;
                int cut2 = (isPeak[i])?1:0;
                peaks = peaks-cut1-cut2;
                if(peaks>maxPeaks){
                    maxPeaks = peaks;
                }
            }
            if(maxPeaks==0)
            System.out.println("0 1");
            else{
            int ans = 0;
            for(int i=1;i<=n-k+1;i++){
                int peaks = p[i+k-1]-p[i];
                int cut1 = (isPeak[i+k-1])?1:0;
                int cut2 = (isPeak[i])?1:0;
                peaks = peaks-cut1-cut2;
                if(peaks==maxPeaks){
                    ans = i;
                    break;
                }
            }
            System.out.println(maxPeaks+1+" "+ans);
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class B1341 {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		solve();
	}
	public static void solve() throws IOException {
		st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int count = 0;
		for(int sss = 0;sss<n;sss++) {
			st = new StringTokenizer(br.readLine());
			int t = Integer.parseInt(st.nextToken()), k = Integer.parseInt(st.nextToken());
			int[]arr = new int[t];
			st = new StringTokenizer(br.readLine());
			for(int i = 0;i<t;i++) {
				arr[i] = Integer.parseInt(st.nextToken());
			}
			int[] cnt = new int[t];
			for(int i = 1;i<t-1;i++) {
				if(arr[i]>arr[i+1]&&arr[i-1]<arr[i])cnt[i] = 1;;
			}
			int sum = 0;
			int maxS = 0;
			int index = 1;
			for(int i = 1;i<k-1;i++) {
				sum+=cnt[i];
			}
			///for(int x:cnt)System.out.print(x+" ");
			//System.out.println();
			maxS = sum;
			for(int i = 2;i<=t-k+1;i++) {
				sum-=cnt[i-1];
				sum+=cnt[i+k-3];
				if(sum>maxS) {
					maxS = sum;
					index = i;
				}
				//System.out.println(sum+" "+(i-1)+" "+(i+k-2));
			}
			System.out.println((maxS+1)+" "+(index));
		}
	}

}


import java.util.Arrays;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        in.nextLine();

        for (int z = 0; z < t; z++) {
            int n = in.nextInt(), k = in.nextInt();
            int[] peaks = new int[n];
            int first = in.nextInt();
            int second = in.nextInt();
            for (int i = 2; i < n; i++) {
                int third = in.nextInt();
                if (third < second && second > first) {
                    peaks[i - 1] = 1;
                }
                first = second;
                second = third;
            }
            int[] pref = new int[n];
            int sum = 0;
            int j = 0;
            for (int i : peaks) {
                sum += i;
                pref[j] = sum;
                j++;
            }
            int l = -1;
            int ans = -1;
            for (int i = 0; i < n - k + 1; i++) {
                int cur = pref[i + k - 2] - pref[i];
                if (cur + 1 > ans) {
                    ans = cur + 1;
                    l = i + 1;
                }
            }
            System.out.println(ans + " " + l);
        }

        in.close();
    }

}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Codechef  {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner scn = new Scanner(System.in);
		long t = scn.nextLong();

		while(t-->0) {

			long n = scn.nextLong();
			long k = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0;  i < n; i++) {
				a[i] = scn.nextLong();
			}

			boolean[] peak = new boolean[(int)n];

			for(int i = 1; i < n-1; i++) {
				peak[i] = (a[i]>a[i-1])&&(a[i]>a[i+1]);
			}

			long[] pre = new long[(int)n];
			pre[0] = 0;
			for(int i = 1; i < n; i++) {
				pre[i] = pre[i-1] + (peak[i]?1:0);
			}

			int j = 0;
			long sum = 1;
			long l = 0;

			for(int i = (int)n-1; i>=1  &&  i-(int)k+1 >=0; i--) {
				j = i-(int)k+1;

				long temp = pre[i-1] - pre[j];

				if(temp>=sum) {
					sum = temp;
					l = j;
				}
			}
			sum++;
			l++;

			System.out.println(sum + " " +l);

		}
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class Codechef  {

	public static void main (String[] args) throws java.lang.Exception {
		Scanner scn = new Scanner(System.in);
		long t = scn.nextLong();

		while(t-->0) {

			long n = scn.nextLong();
			long k = scn.nextLong();

			long[] a = new long[(int)n];
			for(int i = 0;  i < n; i++) {
				a[i] = scn.nextLong();
			}

			boolean[] peak = new boolean[(int)n];

			for(int i = 1; i < n-1; i++) {
				peak[i] = (a[i]>a[i-1])&&(a[i]>a[i+1]);
			}

			long[] pre = new long[(int)n];
			pre[0] = 0;
			for(int i = 1; i < n; i++) {
				pre[i] = pre[i-1] + (peak[i]?1:0);
			}

			int j = 0;
			long sum = 0;
			long l = 0;

			for(int i = (int)n-1; i>=1  &&  i-(int)k+1 >=0; i--) {
				j = i-(int)k+1;

				long temp = pre[i-1] - pre[j];

				if(temp>=sum) {
					sum = temp;
					l = j;
				}
			}
			sum++;
			l++;

			System.out.println(sum + " " +l);

		}
	}
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        int t = scan.nextInt();

        while (t-- > 0) {
            int n = scan.nextInt();
            int k = scan.nextInt();

            int[] arr = new int[n];
            for(int i=0;i<n;i++) {
                arr[i] = scan.nextInt();
            }

            int[] peakCnt = new int[n];
            int cnt = 0;

            for(int i=1;i<n-1;i++) {
                if(arr[i] > arr[i-1] && arr[i] > arr[i+1]) {
                    cnt++;
                }
                peakCnt[i] = cnt;
            }

            peakCnt[n-1] = cnt;

            int ans = 0;
            int l = 0;

            for(int i=0;i<n-k+2;i++) {
                if(ans < peakCnt[i+k-2] - peakCnt[i] + 1){
                    ans = peakCnt[i+k-2] - peakCnt[i] + 1;
                    l = i+1;
                }

            }

            System.out.println(ans+" "+l);
        }
    }

}


import java.util.*;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int a[]=new int[n];
			boolean p[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(a[i]>a[i-1] && a[i]>a[i+1])
					p[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=0;i<n;i++)
			{
				if(i==k-1)
					f=true;
				if(f)
				{
					if(p[j])
						count--;
					j++;
				}
				if(p[i])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			if(max==0)
				System.out.println(0+" "+0);
			else
				System.out.println((max+1)+" "+(ind+1));
		}
	}
}


import java.util.*;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int a[]=new int[n];
			boolean p[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(a[i]>a[i-1] && a[i]>a[i+1])
					p[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=0;i<n;i++)
			{
				if(i==k-1)
					f=true;
				if(f)
				{
					j++;
					if(p[j])
						count--;
				}
				if(p[i])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			if(max==0)
				System.out.println(0+" "+0);
			else
				System.out.println((max+1)+" "+(ind+1));
		}
	}
}


import java.util.*;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int a[]=new int[n];
			boolean p[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(a[i]>a[i-1] && a[i]>a[i+1])
					p[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=1;i<n;i++)
			{
				if(i==k)
					f=true;
				if(f)
				{
					j++;
					if(p[j])
						count--;
				}
				if(p[i-1])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			System.out.println((max+1)+" "+(ind+1));
		}
	}
}


import java.util.*;

public class Solution {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int t=in.nextInt();
		while(t-->0)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			int a[]=new int[n];
			boolean p[]=new boolean[n];
			for(int i=0;i<n;i++)
				a[i]=in.nextInt();
			int max=Integer.MIN_VALUE,count=0,ind=-1;
			for(int i=1;i<n-1;i++)
			{
				if(a[i]>a[i-1] && a[i]>a[i+1])
					p[i]=true;
			}
			int j=0;
			boolean f=false;
			for(int i=1;i<n;i++)
			{
				if(i==k)
					f=true;
				if(f)
				{
					j++;
					if(p[j])
						count--;
				}
				if(p[i-1])
					count++;
				if(max<count)
				{
					max=count;
					ind=j;
				}
			}
			if(max==0)
				System.out.println(0+" "+0);
			else
				System.out.println((max+1)+" "+(ind+1));
		}
	}
}


import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        for(int tt=0;tt<t;tt++){
            int n = s.nextInt();
            int k = s.nextInt();
            int[] a = new int[n];
            for(int i=0;i<n;i++){
                a[i] = s.nextInt();
            }
            int max = 0;
            int index = 0;
            int curr = 0;
            // first segment is from 0 to k-1
            for(int i=1;i<=k-2;i++)
            {
                if(a[i]>a[i-1] && a[i]>a[i+1])
                max++;
            }
            curr = max;
            //System.out.println(curr);
            for(int i=k;i<n;i++)
            {
                // add i to window and remove i-kth from window
                if( (i-2)>=0 &&  a[i-1]>a[i-2] && a[i-1]>a[i] )
                curr++;
                if( (i-k)>=0 && (i-k+2)<n && a[i-k+1]>a[i-k] && a[i-k+1]>a[i-k+2] )
                curr--;
                if(curr>max)
                {
                    max= curr;
                    index = i-k+1;
                }
            }
            max++;
            index++;
            System.out.println(max+" "+index);
        }
    }
}


import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int t = s.nextInt();
        for(int tt=0;tt<t;tt++){
            int n = s.nextInt();
            int k = s.nextInt();
            int[] a = new int[n];
            for(int i=0;i<n;i++){
                a[i] = s.nextInt();
            }
            int max = 0;
            int index = 0;
            int curr = 0;
            // first segment is from 0 to k-1
            for(int i=1;i<=k-2;i++)
            {
                if(a[i]>a[i-1] && a[i]>a[i+1])
                max++;
            }
            curr = max;
            //System.out.println(curr);
            for(int i=k;i<n;i++)
            {
                // add i to window and remove i-kth from window
                if( (i-2)>=0 &&  a[i-1]>a[i-2] && a[i-1]>a[i] )
                curr++;
                if( (i-k-1)>=0 && (i-k+1)<n && a[i-k]>a[i-k-1] && a[i-k]>a[i-k+1] )
                curr--;
                if(curr>max)
                {
                    max= curr;
                    index = i-k+1;
                }
            }
            max++;
            index++;
            System.out.println(max+" "+index);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class d {
    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
   // static Scanner s=new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        StringBuilder sb=new StringBuilder();
       String[] ss=s();
       int t=i(ss[0]);
       while(t-->0){
           String[] s1=s();
           int n=i(s1[0]);
           int k=i(s1[1]);
           long[] a=new long[n];
           String[] s2=s();
           for(int i=0;i<n;i++){
               a[i]=l(s2[i]);
           }
           int peaks=0;int l=0;int r=k-1;
           for(int i=1;i<k-1;i++){
               if(a[i]>a[i-1]&&a[i]>a[i+1]) peaks++;
           }
           int max=peaks;
           for(int i=k-1;i<n-1;i++){
               if(a[i]>a[i-1]&&a[i]>a[i+1]) peaks++;
               if(a[i+1-k+1]>a[i+1-k+1-1]&&a[i+1-k+1]>a[i+1-k+1+1]) peaks--;
               if(peaks>max){
                   max=peaks;
                   l=i+2-k;r=i+1;
               }
           }sb.append((max+1)+" "+(l+1)+" "+"\n");
       }
        System.out.println(sb.toString());
    }      static String[] s() throws IOException {

        return s.readLine().trim().split("\\s+");
    }

    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class d {
    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
   // static Scanner s=new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        StringBuilder sb=new StringBuilder();
       String[] ss=s();
       int t=i(ss[0]);
       while(t-->0){
           String[] s1=s();
           int n=i(s1[0]);
           int k=i(s1[1]);
           long[] a=new long[n];
           String[] s2=s();
           for(int i=0;i<n;i++){
               a[i]=l(s2[i]);
           }
           int peaks=0;int l=0;int r=k-1;
           for(int i=1;i<k-1;i++){
               if(a[i]>a[i-1]&&a[i]>a[i+1]) peaks++;
           }
           int max=peaks;
           for(int i=k-1;i<n-1;i++){
               if(a[i]>a[i-1]&&a[i]>a[i+1]) peaks++;
               if(a[i+1-k+1]>a[i+1-k+1-1]&&a[i+1-k+1]>a[i+1-k+1+1]) peaks--;
               if(peaks>=max){
                   max=peaks;
                   l=i+1-k;r=i+1;
               }
           }sb.append((max+1)+" "+(l+1)+" "+"\n");
       }
        System.out.println(sb.toString());
    }      static String[] s() throws IOException {

        return s.readLine().trim().split("\\s+");
    }

    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
}


//package B;

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    private static final long mod = (long) (1e9 + 7);

    public static void solve() {
        int t = in.nextInt();

        while (t-- > 0) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] nums = new int[n];

            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }

            Set<Integer> peaks = new HashSet<>();
            int max;
            int start = 0;

            for (int i = 1; i < k - 1; i += 1) {
                if (nums[i] > nums[i - 1] && nums[i] > nums[i + 1])
                    peaks.add(i);
            }

            max = peaks.size();
//            out.println(max);

            for (int i = k - 1; i < n - 1; i += 1) {
                peaks.remove(i - (k - 2));

                if (nums[i] > nums[i - 1] && nums[i] > nums[i + 1])
                    peaks.add(i);

                if (peaks.size() > max) {
                    start = i - (k - 2);
                    max = peaks.size();
                }

            }

            out.println((max + 1) + " " + (start + 1));
        }
    }

    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    private static long pow(long a, long b) {
        if (b == 0)
            return 1L;

        long val = pow(a, b / 2);

        if (b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }

    private static class Pair<K, V> {
        K first;
        V second;

        public Pair(K first, V second) {
            this.first = first;
            this.second = second;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}


package B;

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    private static final long mod = (long) (1e9 + 7);

    public static void solve() {
        int t = in.nextInt();

        while(t-- > 0) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] nums = new int[n];

            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }

            Set<Integer> peaks = new HashSet<>();
            int max;
            int start = 0;

            for(int i = 1; i < k-1; i += 1) {
                if(nums[i] > nums[i-1] && nums[i] > nums[i+1])
                    peaks.add(i);
            }

            max = peaks.size();
//            out.println(max);

            for(int i = k-1; i < n-1; i += 1) {
                peaks.remove(i-(k-2));

                if(nums[i] > nums[i-1] && nums[i] > nums[i+1])
                    peaks.add(i);

                if(peaks.size() > max) {
                    start = i-(k-2);
                    max = peaks.size();
                }

            }

            out.println((max+1) + " " + (start+1));
        }
    }

    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    private static long pow(long a, long b) {
        if (b == 0)
            return 1L;

        long val = pow(a, b / 2);

        if (b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }

    private static class Pair<K, V> {
        K first;
        V second;

        public Pair(K first, V second) {
            this.first = first;
            this.second = second;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}


//package B;

import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    private static final long mod = (long) (1e9 + 7);

    public static void solve() {
        int t = in.nextInt();

        while(t-- > 0) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] nums = new int[n];

            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }

            Set<Integer> peaks = new HashSet<>();
            int max;
            int start = 0;

            for(int i = 1; i < k-1; i += 1) {
                if(nums[i] > nums[i-1] && nums[i] > nums[i+1])
                    peaks.add(i);
            }

            max = peaks.size();
//            out.println(max);

            for(int i = k-1; i < n-1; i += 1) {
                peaks.remove(i-(k-1));

                if(nums[i] > nums[i-1] && nums[i] > nums[i+1])
                    peaks.add(i);

                if(peaks.size() > max) {
                    start = i-(k-2);
                    max = peaks.size();
                }

            }

            out.println((max+1) + " " + (start+1));
        }
    }

    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    private static long pow(long a, long b) {
        if (b == 0)
            return 1L;

        long val = pow(a, b / 2);

        if (b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }

    private static class Pair<K, V> {
        K first;
        V second;

        public Pair(K first, V second) {
            this.first = first;
            this.second = second;
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public final class B {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int t = fs.nextInt();
        for (int test = 0; test < t; test++) {
            final int n = fs.nextInt();
            final int k = fs.nextInt();
            final int[] arr = fs.nextIntArray(n);
            int resStart = 0;
            int resPeaks = 0;
            int window = k - 2;
            int j = 1;
            int currPeaks = 0;
            for (int i = 1; i < n -1; i++) {
                currPeaks += isPeak(i, arr) ? 1 : 0;
                window--;
                if (window < 0) {
                    currPeaks -= isPeak(j++, arr) ? 1 : 0;
                    window++;
                }
                if (window == 0) {
                    if (resPeaks < currPeaks) {
                        resPeaks = currPeaks;
                        resStart = j;
                    }
                }
            }
            System.out.println((resPeaks + 1) + " " + resStart);
        }
    }

    private static boolean isPeak(int i, int[] arr) {
        return arr[i - 1] < arr[i] && arr[i] > arr[i + 1];
    }

    static final class Utils {
        public static void shuffleSort(int[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffleSort(long[] x) {
            shuffle(x);
            Arrays.sort(x);
        }

        public static void shuffle(int[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void shuffle(long[] x) {
            final Random r = new Random();

            for (int i = 0; i <= x.length - 2; i++) {
                final int j = i + r.nextInt(x.length - i);
                swap(x, i, j);
            }
        }

        public static void swap(int[] x, int i, int j) {
            final int t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        public static void swap(long[] x, int i, int j) {
            final long t = x[i];
            x[i] = x[j];
            x[j] = t;
        }

        private Utils() {}
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        private String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long[] nextLongArray(int n) {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++) { a[i] = nextLong(); }
            return a;
        }
    }
}