#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

struct v:map<int,pii> {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		--p;
		if (x>p->y.x) return end();
		auto t = *p;
		erase(p);
		emplace(t.x,pii(x-1,t.y.y));
		return emplace(x,t.y).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto L = s.split(l), R = s.split(r+1);
		for (auto t=L; t!=R; ++t) ans += (k-t->y.y)*(t->y.x-t->x+1);
		s.erase(L,R);
		s[l] = {r,k};
		printf("%d\n", ans);
	}
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

struct v:map<int,pii> {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		if (p==begin()) for(;;);
		--p;
		if (x>p->y.x) return end();
		auto t = *p;
		erase(p);
		emplace(t.x,pii(x-1,t.y.y));
		return emplace(x,t.y).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto R = s.split(r+1), L = s.split(l);
		while (L!=R) {
			if (L==s.end()) throw;
			ans += (k-L->y.y)*(L->y.x-L->x+1);
			s.erase(L++);
		}
		s[l] = {r,k};
		printf("%d\n", ans);
	}
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

struct v:map<int,pii> {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		--p;
		if (x>p->y.x) return end();
		auto t = *p;
		erase(p);
		emplace(t.x,pii(x-1,t.y.y));
		return emplace(x,t.y).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto L = s.split(l), R = s.split(r+1);
		if (L->x>R->x) for(;;);
		for (auto t=L; t!=R; ++t) ans += (k-t->y.y)*(t->y.x-t->x+1);
		s.erase(L,R);
		s[l] = {r,k};
		printf("%d\n", ans);
	}
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

struct v:map<int,pii> {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		if (p==begin()) for(;;);
		--p;
		if (x>p->y.x) return end();
		auto t = p->y;
		p->y.x = x-1;
		return emplace(x,t).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto L = s.split(l), R = s.split(r+1);
		while (L!=R) {
			ans += (k-L->y.y)*(L->y.x-L->x+1);
			s.erase(L++);
		}
		s[l] = {r,k};
		printf("%d\n", ans);
	}
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

struct v:map<int,pii> {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		if (p==begin()) for(;;);
		--p;
		if (x>p->y.x) return end();
		auto t = p->y;
		p->y.x = x-1;
		return emplace(x,t).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto R = s.split(r+1), L = s.split(l);
		while (L!=R) {
			ans += (k-L->y.y)*(L->y.x-L->x+1);
			s.erase(L++);
		}
		s[l] = {r,k};
		printf("%d\n", ans);
	}
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

struct v:map<int,pair<int,int> > {
	auto split(int x) {
		auto p = lower_bound(x);
		if (p!=end()&&p->x==x) return p;
		--p;
		if (x>p->y.x) return end();
		auto t = *p;
		erase(p);
		emplace(t.x,pair<int,ll>(x-1,t.y.y));
		return emplace(x,t.y).x;
	}
} s;
int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	s[1] = {n,1};
	int ans = n;
	while (q--) {
		int l,r,k;
		scanf("%d%d%d",&l,&r,&k);
		if (k==1) k = 0;
		else k = 1;
		auto L = s.split(l), R = s.split(r+1);
		for (; L!=R;++L) {
			int len = L->y.x-L->x+1;
			ans += (k-L->y.y)*len;
			L->y.y = k;
		}
		printf("%d\n", ans);
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 6e5 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN << 2];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[u];
    lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(r);
    }
    v.push_back(0);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

int n, m, T[MAXN << 2], lz[MAXN];
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = (mid - l + 1) * lz[u];
    T[ru] = (r - mid) * lz[u];
    lz[lu] = lz[u];
    lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = 1; return; }
    build(lson); build(rson);
    pushup(u);
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = (r - l + 1) * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    build(root);
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        op--;
        update(root, l, r, op);
        cout << T[1] << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3e5 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[u];
    lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(r);
    }
    v.push_back(0);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN << 2];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(l-1);
        v.push_back(r);
    }
    v.push_back(0);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN << 2];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(l-1);
        v.push_back(r);
    }
    v.push_back(0);
    v.push_back(n);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 6e5 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN >> 1];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN << 2];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(r + 1);
    }
    v.push_back(0);
    v.push_back(n + 1);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l + 1) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r + 1) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] - 1 << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 6e5 + 5;
#define root 1,1,n
#define mid ((l+r)>>1)
#define lu u<<1
#define ru u<<1|1
#define lson lu,l,mid
#define rson ru,mid+1,r

struct Node{
    int l, r, op;
}q[MAXN >> 1];
int n, m, sum[MAXN << 2], T[MAXN << 2], lz[MAXN << 2];
vector<int> v;
void pushdown(int u, int l, int r){
    if(lz[u] == -1) return;
    T[lu] = sum[lu] * lz[u];
    T[ru] = sum[ru] * lz[u];
    lz[lu] = lz[ru] = lz[u];
    lz[u] = -1;
}
void pushup(int u){ T[u] = T[lu] + T[ru]; }
void build(int u, int l, int r){
    lz[u] = -1;
    if(l == r){ T[u] = sum[u] = v[l] - v[l-1]; return; }
    build(lson); build(rson);
    pushup(u);
    sum[u] = sum[lu] + sum[ru];
}
void update(int u, int l, int r, int L, int R, int x){
    if(L <= l && r <= R){
        T[u] = sum[u] * x;
        lz[u] = x;
        return;
    }
    pushdown(u, l, r);
    if(L <= mid) update(lson, L, R, x);
    if(R > mid) update(rson, L, R, x);
    pushup(u);
}
int main(){
    #ifdef Irene
    freopen("in.txt", "r", stdin);
    #endif // Irene
    ios::sync_with_stdio(false);

    cin >> n >> m;
    int op, l, r;
    for(int i = 1; i <= m; i++){
        cin >> l >> r >> op;
        q[i] = {l, r, --op};
        v.push_back(l);
        v.push_back(r + 1);
    }
    v.push_back(0);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    n = v.size() - 1;
    build(root);
    for(int i = 1; i <= m; i++){
        l = lower_bound(v.begin(), v.end(), q[i].l + 1) - v.begin();
        r = lower_bound(v.begin(), v.end(), q[i].r + 1) - v.begin();
        op = q[i].op;
        update(root, l, r, op);
        cout << T[1] - 1 << '\n';
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn*60];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
     if(l <= L && R <= r)
     {
         tr[p].val = (R - L + 1) * v;
         tr[p].lazy = v;
         return;
     }
     spread(p, L, R);
     int mid = (L + R) >> 1;
     if(l <= mid)
     {
         if(!tr[p].lc) tr[p].lc = newnode();
         change(tr[p].lc, l, r, L, mid, v);
     }
     if(mid < r)
     {
         if(!tr[p].rc) tr[p].rc = newnode();
         change(tr[p].rc, l, r, mid+1, R, v);
     }
     pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) tr[i].lazy = -1;
    int root = newnode();
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn*40];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
     if(l <= L && R <= r)
     {
         tr[p].val = (R - L + 1) * v;
         tr[p].lazy = v;
         return;
     }
     spread(p, L, R);
     int mid = (L + R) >> 1;
     if(l <= mid)
     {
         if(!tr[p].lc) tr[p].lc = newnode();
         change(tr[p].lc, l, r, L, mid, v);
     }
     if(mid < r)
     {
         if(!tr[p].rc) tr[p].rc = newnode();
         change(tr[p].rc, l, r, mid+1, R, v);
     }
     pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++)
        tr[i].lazy = -1;
    int root = newnode();
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn*45];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
     if(l <= L && R <= r)
     {
         tr[p].val = (R - L + 1) * v;
         tr[p].lazy = v;
         return;
     }
     spread(p, L, R);
     int mid = (L + R) >> 1;
     if(l <= mid)
     {
         if(!tr[p].lc) tr[p].lc = newnode();
         change(tr[p].lc, l, r, L, mid, v);
     }
     if(mid < r)
     {
         if(!tr[p].rc) tr[p].rc = newnode();
         change(tr[p].rc, l, r, mid+1, R, v);
     }
     pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) tr[i].lazy = -1;
    int root = newnode();
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<cstdio>
#include<cstring>
#define Rint register int
using namespace std;
const int N = 15001000;
int n, q, root, seg[N], lazy[N], li[N], ri[N], cnt;
inline void pushup(int x){seg[x] = seg[li[x]] + seg[ri[x]];}
inline void pushdown(int x, int L, int R){
    if(~lazy[x]){
        int mid = L + R >> 1;
        if(!li[x]) li[x] = ++ cnt;
        seg[li[x]] = lazy[x] * (mid - L + 1); lazy[li[x]] = lazy[x];
        if(!ri[x]) ri[x] = ++ cnt;
        seg[ri[x]] = lazy[x] * (R - mid); lazy[ri[x]] = lazy[x];
        lazy[x] = -1;
    }
}
inline void change(int &x, int L, int R, int l, int r, int v){
    if(!x) x = ++ cnt;
    if(l <= L && R <= r){
        seg[x] = (R - L + 1) * v;
        lazy[x] = v;
        return;
    }
    pushdown(x, L, R);
    int mid = L + R >> 1;
    if(l <= mid) change(li[x], L, mid, l, r, v);
    if(mid < r) change(ri[x], mid + 1, R, l, r, v);
    pushup(x);
}
int main(){
    scanf("%d%d", &n, &q);
    memset(lazy, -1, sizeof lazy);
    change(root, 1, n, 1, n, 0);
    while(q --){
        int l, r, k;
        scanf("%d%d%d", &l, &r, &k);
        change(root, 1, n, l, r, 2 - k);
        printf("%d\n", n - seg[1]);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+10;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn*45];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
    if(!p) p = newnode();
    if(l <= L && R <= r)
    {
        tr[p].val = (R - L + 1) * v;
        tr[p].lazy = v;
        return;
    }
    spread(p, L, R);
    int mid = (L + R) >> 1;
    if(l <= mid)
        change(tr[p].lc, l, r, L, mid, v);
    if(mid < r)
        change(tr[p].rc, l, r, mid+1, R, v);
    pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++)
        tr[i].lazy = -1;
    int root = newnode();
    change(root, 1, n, 1, n, 0);
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = 15001000;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
     if(l <= L && R <= r)
     {
         tr[p].val = (R - L + 1) * v;
         tr[p].lazy = v;
         return;
     }
     spread(p, L, R);
     int mid = (L + R) >> 1;
     if(l <= mid)
     {
         if(!tr[p].lc) tr[p].lc = newnode();
         change(tr[p].lc, l, r, L, mid, v);
     }
     if(mid < r)
     {
         if(!tr[p].rc) tr[p].rc = newnode();
         change(tr[p].rc, l, r, mid+1, R, v);
     }
     pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) tr[i].lazy = -1;
    int root = newnode();
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = (3e5+10) * 40;
int n, q, l, r, k;

int lc[maxn], rc[maxn], lazy[maxn], val[maxn];

int tot;
inline int newnode(){
    tot++;
    return tot;
}

inline void pushup(int p){
    val[p] = val[lc[p]] + val[rc[p]];
}

void spread(int p, int l, int r)
{
    if(lazy[p] != -1)
    {
        int mid = (l + r) >> 1;

        if(!lc[p]) lc[p] = newnode();
        val[lc[p]] = lazy[p] * (mid - l + 1);
        lazy[lc[p]] = lazy[p];

        if(!rc[p]) rc[p] = newnode();
        val[rc[p]] = lazy[p] * (r - (mid+1) + 1);
        lazy[rc[p]] = lazy[p];

        lazy[p] = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
    if(!p) p = newnode();
    if(l <= L && R <= r)
    {
        val[p] = (R - L + 1) * v;
        lazy[p] = v;
        return;
    }
    spread(p, L, R);
    int mid = (L + R) >> 1;
    if(l <= mid)
        change(lc[p], l, r, L, mid, v);
    if(mid < r)
        change(rc[p], l, r, mid+1, R, v);
    pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++)
        lazy[i] = -1;
    int root = newnode();
    change(root, 1, n, 1, n, 0);
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - val[root]);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, q, l, r, k;

struct SegmentTree
{
    int lc, rc;
    int val;
    int lazy;
}tr[maxn*80];

int tot;
inline int newnode(){
    tot++;
    tr[tot].lc = tr[tot].rc = tr[tot].val = 0;
    return tot;
}

inline void pushup(int p){
    tr[p].val = tr[tr[p].lc].val + tr[tr[p].rc].val;
}

void spread(int p, int l, int r)
{
    if(tr[p].lazy != -1)
    {
        int mid = (l + r) >> 1;

        if(!tr[p].lc) tr[p].lc = newnode();
        tr[tr[p].lc].val = tr[p].lazy * (mid - l + 1);
        tr[tr[p].lc].lazy = tr[p].lazy;

        if(!tr[p].rc) tr[p].rc = newnode();
        tr[tr[p].rc].val = tr[p].lazy * (r - (mid+1) + 1);
        tr[tr[p].rc].lazy = tr[p].lazy;

        tr[p].lazy = -1;
    }

}

void change(int p, int l, int r, int L, int R, int v)
{
     if(l <= L && R <= r)
     {
         tr[p].val = (R - L + 1) * v;
         tr[p].lazy = v;
         return;
     }
     spread(p, L, R);
     int mid = (L + R) >> 1;
     if(l <= mid)
     {
         if(!tr[p].lc) tr[p].lc = newnode();
         change(tr[p].lc, l, r, L, mid, v);
     }
     if(mid < r)
     {
         if(!tr[p].rc) tr[p].rc = newnode();
         change(tr[p].rc, l, r, mid+1, R, v);
     }
     pushup(p);
}

int main()
{
    scanf("%d%d", &n, &q);
    for(int i = 1; i <= n; i++) tr[i].lazy = -1;
    int root = newnode();
    while(q--)
    {
        scanf("%d%d%d", &l, &r, &k);
        change(1, l, r, 1, n, 2-k);
        printf("%d\n", n - tr[root].val);
    }
    return 0;
}
/*
4
6
1 2 1
3 4 1
2 3 2
1 3 2
2 4 1
1 4 2
*/


#include <bits/stdc++.h>

using namespace std;
struct seg
{
    int l,r;
    seg(int l, int r)
    {
        this->l=l;
        this->r=r;
    }
    bool operator<(seg const b) const
    {
        if(r!=b.r)
            return r<b.r;
        return l<b.l;
    }
};
int n,q,l,r,t,ans;
set<seg> s;

void dif(seg a, seg b)
{
    if(a.r>b.r)
    {
        s.insert(seg(b.r+1, a.r));
        ans+=a.r-b.r;
    }
    if(a.l<b.l)
    {
        s.insert(seg(a.l, b.l-1));
        ans+=b.l-a.l;
    }
}
void upd(seg a)
{
    auto it=s.lower_bound(seg(0, a.l));

    while(it!=s.end())
    {
        if(it->l<=a.r)
        {
            dif(*it, a);

            ans-=it->r-it->l+1;
            it=s.erase(it);
        }
        else
            break;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>q;
    while(q)
    {
        q--;
        cin>>l>>r>>t;
        if(t==1)
        {
            upd(seg(l, r));
            s.insert(seg(l, r));
            ans+=r-l+1;
        }
        else
        {
            upd(seg(l, r));
        }

        cout<<n-ans<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
struct seg
{
    int l,r;
    seg(int l, int r)
    {
        this->l=l;
        this->r=r;
    }
    bool operator<(seg b) const
    {
        if(r!=b.r)
            return r<b.r;
        return l<b.l;
    }
};
int n,q,l,r,t,ans;
set<seg> s;
bool inter(seg a, seg b)
{
    return a.l<=b.r;
}
void dif(seg a, seg b)
{
    if(a.r>b.r)
    {
        s.insert(seg(b.r+1, a.r));
        ans+=a.r-b.r;
    }
    if(a.l<b.l)
    {
        s.insert(seg(a.l, b.l-1));
        ans+=b.l-a.l;
    }
}
void upd(seg a)
{
    auto it=s.lower_bound(seg(0, a.l));

    while(it!=s.end())
    {
        if(inter(*it, a))
        {
            dif(*it, a);

            ans-=it->r-it->l+1;
            it=s.erase(it);
        }
        else
            it++;
    }
}
int main()
{
    cin>>n>>q;
    while(q)
    {
        q--;
        cin>>l>>r>>t;
        if(t==1)
        {
            upd(seg(l, r));
            s.insert(seg(l, r));
            ans+=r-l+1;
        }
        else
        {
            upd(seg(l, r));
        }

        cout<<n-ans<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
struct seg
{
    int l,r;
    seg(int l, int r)
    {
        this->l=l;
        this->r=r;
    }
    bool operator<(seg const b) const
    {
        if(r!=b.r)
            return r<b.r;
        return l<b.l;
    }
};
int n,q,l,r,t,ans;
set<seg> s;

void dif(seg a, seg b)
{
    if(a.r>b.r)
    {
        s.insert(seg(b.r+1, a.r));
        ans+=a.r-b.r;
    }
    if(a.l<b.l)
    {
        s.insert(seg(a.l, b.l-1));
        ans+=b.l-a.l;
    }
}
void upd(seg a)
{
    auto it=s.lower_bound(seg(0, a.l));

    while(it!=s.end())
    {
        if(it->l<=a.r)
        {
            dif(*it, a);

            ans-=it->r-it->l+1;
            it=s.erase(it);
        }
        else
            it++;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>q;
    while(q)
    {
        q--;
        cin>>l>>r>>t;
        if(t==1)
        {
            upd(seg(l, r));
            s.insert(seg(l, r));
            ans+=r-l+1;
        }
        else
        {
            upd(seg(l, r));
        }

        cout<<n-ans<<'\n';
    }
    return 0;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
public class Main{
public static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.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);
    }
}

	static void mergeSort(int[] input,int start,int end)
    {
        if(start>end || start==end)
            return;
        int mid=(start+end)/2;
        mergeSort(input,start,mid);
        mergeSort(input,mid+1,end);

        merge(input,start,end);

    }
    static void merge(int input[],int start,int end)
    {
        int sorted[] = new int[end-start+1];
        int mid=(start+end)/2;
        int i=start,j=mid+1,count=0;

        while(i<=mid && j<=end)
        {
            if(input[i]>input[j])
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
            else
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        if(i>mid)
        {
            while(j<=end)
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
        }
        else
        {
            while(i<=mid)
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        for(i=start;i<=end;i++)
        {
            input[i]=sorted[i-start];
        }
    }

    public static void main(String[] args)
    {
       InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
       int t=sc.nextInt();
while(t-->0)
{
    int n=sc.nextInt();
    int k=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]=sc.nextInt();
    }
    int l=0,p=0,cp=0;
    for(int i=0;i<n-k+1;i++)
    {
        cp=0;
        for(int j=i+1;j<i+k-1;j++)
        {
            if(a[j-1]<a[j] && a[j+1]<a[j])
            cp++;
        }
        if(cp>p)
        {
            p=cp;
            l=i;
        }
    }
   w.println((p+1)+" "+(l+1));
}
	w.close();
	}
 }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
public class Main{
public static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.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);
    }
}

	static void mergeSort(int[] input,int start,int end)
    {
        if(start>end || start==end)
            return;
        int mid=(start+end)/2;
        mergeSort(input,start,mid);
        mergeSort(input,mid+1,end);

        merge(input,start,end);

    }
    static void merge(int input[],int start,int end)
    {
        int sorted[] = new int[end-start+1];
        int mid=(start+end)/2;
        int i=start,j=mid+1,count=0;

        while(i<=mid && j<=end)
        {
            if(input[i]>input[j])
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
            else
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        if(i>mid)
        {
            while(j<=end)
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
        }
        else
        {
            while(i<=mid)
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        for(i=start;i<=end;i++)
        {
            input[i]=sorted[i-start];
        }
    }

    public static void main(String[] args)
    {
       InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
       int t=sc.nextInt();
while(t-->0)
{
    int n=sc.nextInt();
    int k=sc.nextInt();
    int[] a=new int[n];
    for(int i=0;i<n;i++)
    {
        a[i]=sc.nextInt();
    }
    long[] b=new long[n];
    long l=0,p=0,cp=0;
    for(int i=1;i<n-1;i++)
    {
        if(a[i-1]<a[i] && a[i+1]<a[i])
            cp++;
           b[i]=cp;
    }
    b[n-1]=cp;
    k-=2;
    for(int i=0;i<n-k;i++)
    {
        if(b[i+k]-b[i]>p)
        {
            l=i+1;
            p=b[i+k]-b[i];
        }
    }

   w.println((p+1)+" "+l);
}
	w.close();
	}
 }


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
public class Main{
public static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.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);
    }
}

	static void mergeSort(int[] input,int start,int end)
    {
        if(start>end || start==end)
            return;
        int mid=(start+end)/2;
        mergeSort(input,start,mid);
        mergeSort(input,mid+1,end);

        merge(input,start,end);

    }
    static void merge(int input[],int start,int end)
    {
        int sorted[] = new int[end-start+1];
        int mid=(start+end)/2;
        int i=start,j=mid+1,count=0;

        while(i<=mid && j<=end)
        {
            if(input[i]>input[j])
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
            else
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        if(i>mid)
        {
            while(j<=end)
            {
                sorted[count]=input[j];
                j++;
                count++;
            }
        }
        else
        {
            while(i<=mid)
            {
                sorted[count]=input[i];
                i++;
                count++;
            }
        }
        for(i=start;i<=end;i++)
        {
            input[i]=sorted[i-start];
        }
    }

    public static void main(String[] args)
    {
       InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader sc = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
       int t=sc.nextInt();
while(t-->0)
{
    int n=sc.nextInt();
    long k=sc.nextLong();
    long[] a=new long[n];
    for(int i=0;i<n;i++)
    {
        a[i]=sc.nextLong();
    }
    long[] b=new long[n];
    long l=0,p=0,cp=0;
    for(int i=1;i<n-1;i++)
    {
        if(a[i-1]<a[i] && a[i+1]<a[i])
            cp++;
           b[i]=cp;
    }
    b[n-1]=0;
    b[0]=0;
    k-=2;
    for(long i=0;i<n-k;i++)
    {
        if(b[(int)(i+k)]-b[(int)i]>p)
        {
            l=i;
            p=b[(int)(i+k)]-b[(int)i];
        }
    }

   w.println((p+1)+" "+(l+1));
}
	w.close();
	}
 }


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

      public static void main(String[] args)throws IOException{
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         int itr =Integer.parseInt(br.readLine());
         while(itr-->0){
               String[] str = br.readLine().split(" ");
               int n = Integer.parseInt(str[0]);
               int k = Integer.parseInt(str[1]);
               String[] str0  = br.readLine().split(" ");
               long[] arr  = new long[n];
               for(int i =0 ;i<n ;i++)
                  arr[i]  = Long.parseLong(str0[i]);

               int max = -1;
               int l = -1;
               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;

               }
               for(int i = 1;i<n ;i++)
                       p[i] +=p[i-1];

               for(int i =0 ,j = k-1;j<n ;i++,j++){
                     int temp = p[j-1]-p[i];
                     if(temp>max){
                        l =i;
                        max = temp;
                     }
               }

              System.out.println((max+1)+" "+(l+1));

         }
      }
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{

      public static void main(String[] args)throws IOException{
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         int itr =Integer.parseInt(br.readLine());
         while(itr-->0){
               String[] str = br.readLine().split(" ");
               int n = Integer.parseInt(str[0]);
               int k = Integer.parseInt(str[1]);
               String[] str0  = br.readLine().split(" ");
               long[] arr  = new long[n];
               for(int i =0 ;i<n ;i++)
                  arr[i]  = Long.parseLong(str0[i]);

               int max = 0;
               int l = 0;
               for(int i = 0 ;i<=n-k ;i++){
                        int count = 0;
                        int lim = i+k;
                        int index = i+1;
                        while(index<lim){
                               if(index+1<i+k && arr[index-1]<arr[index] && arr[index+1]<arr[index]){
                                        index +=2;
                                        count++;
                               }else{
                                        index++;
                               }
                       }
                    //   System.out.println(count+" :count");
                       if(count>max){
                                max = count;
                                l = i;

                       }

               }

              System.out.println((max+1)+" "+(l+1));

         }
      }
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{

      public static void main(String[] args)throws IOException{
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         int itr =Integer.parseInt(br.readLine());
         while(itr-->0){
               String[] str = br.readLine().split(" ");
               int n = Integer.parseInt(str[0]);
               int k = Integer.parseInt(str[1]);
               String[] str0  = br.readLine().split(" ");
               long[] arr  = new long[n];
               for(int i =0 ;i<n ;i++)
                  arr[i]  = Long.parseLong(str0[i]);

               int max = 0;
               int l = 0;
               for(int i = 0 ;i<=n-k ;i++){
                        int count = 0;
                        int lim = i+k;
                        int index = i+1;
                        while(index<lim){
                               if(index+1<i+k && arr[index-1]<arr[index] && arr[index+1]<arr[index]){
                                        index +=2;
                                        count++;
                               }else{
                                        index++;
                               }
                       }
                    //   System.out.println(count+" :count");
                       if(count>max){
                                max = count;
                                l = i;

                       }

               }

              System.out.println((max+1)+" "+(l+1));

         }
      }
}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int t = input.nextInt();

        for(int u=0; u < t; u++) {
            int n = input.nextInt();
            int k = input.nextInt();

            int[] a = new int[n];
            boolean[] peak = new boolean[n];

            for(int i=0; i < n; i++) {
                a[i] = input.nextInt();
                peak[i] = false;
            }

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

            int curCount = 0;
            int maxCount = 0;
            int maxLeft = 0;

            for(int i=0; true; i++) {
                curCount = 0;
                int j = i;
                for(; j < i + k-1; j++) {
                    if (peak[j]) curCount++;
                }
                if (curCount > maxCount) {
                    maxCount = curCount;
                    maxLeft = i;
                }
                if (j == n) break;
            }

            System.out.println((maxCount+1) + " " + (maxLeft+1));
        }
    }

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int t = input.nextInt();

        for(int u=0; u < t; u++) {
            int n = input.nextInt();
            int k = input.nextInt();

            int[] a = new int[n];
            int[] peak = new int[n];

            for(int i=0; i < n; i++) {
                a[i] = input.nextInt();
                peak[i] = 0;
            }

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

            int maxCount = 0;

            for(int i=1; i + 1 < k; i++) {
                maxCount += peak[i];
            }

            int answer = maxCount;
            int left = 0;
            for(int i=k; i < n; i++) {
                maxCount += (peak[i-1] - peak[i-k+1]);

                if (maxCount > answer) {
                    answer = maxCount;
                    left = i - k + 1;
                }
            }

            System.out.println((answer + 1) + " " + (left + 1));
        }
    }

}


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        int t = input.nextInt();

        for(int u=0; u < t; u++) {
            int n = input.nextInt();
            int k = input.nextInt();

            int[] a = new int[n];
            boolean[] peak = new boolean[n];

            for(int i=0; i < n; i++) {
                a[i] = input.nextInt();
                peak[i] = false;
            }

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

            int curCount = 0;
            int maxCount = 0;
            int maxLeft = 0;

            for(int i=0; i < n-k+1; i++) {
                curCount = 0;
                for(int j=i; j < i + k-1; j++) {
                    if (peak[j]) curCount++;
                }
                if (curCount > maxCount) {
                    maxCount = curCount;
                    maxLeft = i;
                }
            }

            System.out.println((maxCount+1) + " " + (maxLeft+1));
        }
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int t;
        t = in.nextInt();
        while (t > 0) {
            solver.call(in,out);
            t--;
        }
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int n , k , a=0 , b=Integer.MIN_VALUE, c=0 ;
            n = in.nextInt();
            k = in.nextInt();
            int[] arr = new int[n];
            int[] array = new int[n];
            for (int i = 0; i < n ; i++) {
                arr[i] = in.nextInt();
            }
            for (int i = 1; i <n-1 ; i++) {
                if(arr[i]>arr[i+1] && arr[i]>arr[i-1]){
                    array[i]=1;
                }
            }
//            for (int i = 0; i <n ; i++) {
//                System.out.println(array[i]);
//            }
            for (int i = 0; i <=n-k ; i++) {
                a=0;
                for (int j = 0; j <k-2; j++) {
                    if(array[i+j+1]==1)
                        a++;
                }
                if(a>b){
                    b=a;
                    c=i;
                }
            }
            out.println((b+1)+" "+(c+1));
        }
    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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 long nextLong(){
            return Long.parseLong(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int t;
        t = in.nextInt();
        while (t > 0) {
            solver.call(in,out);
            t--;
        }
        out.close();
    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int n , k , a=0 , b=Integer.MIN_VALUE, c=0 ,d=1 , e =0 ;
            n = in.nextInt();
            k = in.nextInt();
            int[] arr = new int[n];
            int[] array = new int[n];
            for (int i = 0; i < n ; i++) {
                arr[i] = in.nextInt();
            }
            for (int i = 1; i <n-1 ; i++) {
                if(arr[i]>arr[i+1] && arr[i]>arr[i-1]){
                    array[i]=1;
                }
            }

            for (int i = 0; i <n ; i++) {
                if(d+1==k){
                    if(a>b){
                        b=a;
                        c=e+1;
                    }
                    a=0;
                    d=1;
                    e++;
                    i= i -(k-1);
                    i++;
                    if(e==n-k+1)
                        break;
                    continue;
                }
                if(array[i+1]==1)
                    a++;
                d++;
            }

            out.println((b+1)+" "+(c));
        }
    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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 long nextLong(){
            return Long.parseLong(next());
        }

    }
}


import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        int t;
        t = in.nextInt();
        while (t > 0) {
            solver.call(in,out);
            t--;
        }
        out.close();

    }

    static class TaskA {
        public void call(InputReader in, PrintWriter out) {
            int n , k , a=0 , b=Integer.MIN_VALUE, c=0 ,d = 0;
            n = in.nextInt();
            k = in.nextInt();
            int[] arr = new int[n];
            int[] array = new int[n];

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

            a=1;

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

                if(i==k-2){
                    if(c>b){
                        b = c;
                        d = a;
                    }
                    if(array[a]==1)
                        c--;
                    a++;
                }
                else{
                    if(a>1){
                        if(c>b){
                            b = c;
                            d = a ;
                        }
                        if(array[a]==1)
                            c--;
                        a++;

                    }
                }
            }

            out.println(b+1+" "+d);

        }
    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            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 long nextLong(){
            return Long.parseLong(next());
        }

    }
}


import java.util.*;
import java.util.ArrayList;
public class Main{
     static class Pair{
     int x;
     int y;
       Pair(){

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

    public static void main(String[] args)
    {
    Scanner param = new Scanner(System.in);
    int end=param.nextInt();
    while(end-->0){
   int n=param.nextInt();
   int k=param.nextInt();
   int arr[]=new int[n];
   for(int i=0;i<n;i++){
   arr[i]=param.nextInt();
   }
   int p=-1;
   int count=0;
   int sum=0;
   int sumer=0;
   boolean b=false;
   int z=0;
   int l=0;
   Queue<Integer>q=new LinkedList<>();
   int m=0;

   for(int i=0;i<n;i++){
   count++;

   if(count>=k){

   if(sum<sumer)
   {
       //System.out.println(sumer);
     //System.out.println(count);

   sum=sumer;
   p=z;
   //System.out.println(p);
   }
   z++;

  // System.out.println(l);
  if(q.size()>0&&count-k>=q.peek()){
  sumer=Math.max(0,sumer-1);
  q.poll();
  }
  else{
  sumer=sumer;
  }

   }
   if(i==0||i==n-1){
   continue;
   }
   if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
   sumer++;
   q.add(i-1);
   }

   }

   if(sum==0){
       p=0;
   }
   System.out.print(sum+1+" "+(p+1));
   System.out.println();

}
}
}


import java.util.*;
import java.util.ArrayList;
public class Main{
     static class Pair{
     int x;
     int y;
       Pair(){

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

    public static void main(String[] args)
    {
    Scanner param = new Scanner(System.in);
    int end=param.nextInt();
    while(end-->0){
   int n=param.nextInt();
   int k=param.nextInt();
   int arr[]=new int[n];
   for(int i=0;i<n;i++){
   arr[i]=param.nextInt();
   }
   int p=-1;
   int count=0;
   int sum=0;
   int sumer=0;
   boolean b=false;
   int z=0;
   int l=0;

   for(int i=0;i<n;i++){
   count++;

   if((count-z)%k==0){

   if(sum<sumer){
   sum=sumer;
   p=z;
   }
   z++;
   b=false;
  if(z>=l+1){
  sumer=Math.max(0,sumer-1);
  }
  else{
  sumer=sumer;
  }

   }
   if(i==0||i==n-1){
   continue;
   }
   if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
   sumer++;
   if(b==false){
   b=true;
   l=i-1;
   }
   }

   }

   System.out.print(sum+1+" "+(p+1));
   System.out.println();

}

}
}


import java.util.*;
import java.util.ArrayList;
public class Main{
     static class Pair{
     int x;
     int y;
       Pair(){

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

    public static void main(String[] args)
    {
    Scanner param = new Scanner(System.in);
    int end=param.nextInt();
    while(end-->0){
   int n=param.nextInt();
   int k=param.nextInt();
   int arr[]=new int[n];
   for(int i=0;i<n;i++){
   arr[i]=param.nextInt();
   }
   int p=-1;
   int count=0;
   int sum=0;
   int sumer=0;
   boolean b=false;
   int z=0;
   int l=0;
   int arr1[]=new int[n];

   for(int i=0;i<n;i++){
   if(i==0||i==n-1){
   continue;
   }
   if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
   arr1[i]=1;
   }
   }

   for(int i=1;i<n;i++){
   arr1[i]+=arr1[i-1];
   }
   for(int i=k-2;i<n;i++)
   {
   if(arr1[i]-arr1[i-k+2]>sum){
   sum=arr1[i]-arr1[i-k+2];
   z=i-k+2;
   }
   }

   System.out.println((sum+1)+" "+(z+1));

}
}
}


import java.util.*;
import java.util.ArrayList;
public class Main{
     static class Pair{
     int x;
     int y;
       Pair(){

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

    public static void main(String[] args)
    {
    Scanner param = new Scanner(System.in);
    int end=param.nextInt();
    while(end-->0){
   int n=param.nextInt();
   int k=param.nextInt();
   int arr[]=new int[n];
   for(int i=0;i<n;i++){
   arr[i]=param.nextInt();
   }
   int p=-1;
   int count=0;
   int sum=0;
   int sumer=0;
   boolean b=false;
   int z=0;
   int l=0;

   for(int i=0;i<n;i++){
   count++;

   if((count-z)%k==0){

   if(sum<sumer){
   sum=sumer;
   p=z;
   }
   z++;
   b=false;
  if(z>l+1){
  sumer=Math.max(0,sumer-1);
  }
  else{
  sumer=sumer;
  }

   }
   if(i==0||i==n-1){
   continue;
   }
   if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
   sumer++;
   if(b==false){
   b=true;
   l=i-1;
   }
   }

   }

   System.out.print(sum+1+" "+(p+1));
   System.out.println();

}

}
}


import java.util.Scanner;

public class probB {
    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();
            long[] a = new long[n];
            for(int i =0;i<n;i++){
                a[i] = sc.nextLong();
            }
            int p =0;int max=0;
            for(int i=0;i<=n-k;i++){
                int count=0;
                for(int j =i;j<i+k-2;j++){
                    if(a[j]<a[j+1] && a[j+2]<a[j+1]){
                        count++;
                    }
                }
                    if(count>max){
                        max=count;
                        p=i;
                    }
                }
            System.out.print(max+1+" ");
            System.out.println(p+1);
        }
    }
}


import java.util.Scanner;
import java.util.Vector;

public class probB {
    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();
            long[] a = new long[n];
            for(int i =0;i<n;i++){
                a[i] = sc.nextLong();
            }
            int p =0;int max=0;
            Vector<Long> v = new Vector<Long>();
            int[] c = new int[n];
            int count =0;
            c[0]=0;
            for(int i=0;i<n-2;i++){
                if(a[i]<a[i+1] && a[i+2]<a[i+1]){
                    count++;
                }
                c[i+1] =count;
                }
            c[n-1] = c[n-2];
            for(int i=0;i<=n-k;i++){
                int j = i+k-1;
                int max1 = c[j - 1] - c[i];
                if(max1 > max){
                    max = max1;
                    p=i;
                }

            }
            StringBuilder sb = new StringBuilder();
            sb.append((max+1)+" "+(p+1)+"\n");
            System.out.print(sb);
        }
    }
}


import java.util.Scanner;
import java.util.Vector;

public class probB {
    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();
            long[] a = new long[n];
            for(int i =0;i<n;i++){
                a[i] = sc.nextLong();
            }
            int p =0;int max=0;
            Vector<Long> v = new Vector<Long>();
            for(int i=0;i<n-2;i++){
                if(a[i]<a[i+1] && a[i+2]<a[i+1]){
                    v.add((long)i+1);
                }
                }
            int count =0;
            for(int i=0;i<=n-k;i++){
                count =0;
                for(int j=0;j<v.size();j++){
                    if(v.get(j)>i && v.get(j)<(i+k-1)) count++;
                }
                if(count>max){
                    max = count;
                    p=i;
                }
            }

            System.out.print(max+1+" ");
            System.out.println(p+1);
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
    public static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.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);
        }
    }

    static long gcd(long a, long b){
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    static long lcm(long a, long b)  {
        return (a*b)/gcd(a, b);
    }
    public static void sortbyColumn(int arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<int[]>() {

          @Override

          public int compare(final int[] entry1,
                             final int[] entry2) {

            if (entry1[col] > entry2[col])
                return 1;
            else
                return -1;
          }
        });
    }
    static long func(long a[],long size,int s){
        long max1=a[s];
        long maxc=a[s];
        for(int i=s+1;i<size;i++){
            maxc=Math.max(a[i],maxc+a[i]);
            max1=Math.max(maxc,max1);
        }
        return max1;
    }
    public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
        public U x;
        public V y;

        public Pair(U x, V y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode());
        }

        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair<U, V> p = (Pair<U, V>) o;
            return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y));
        }

        public int compareTo(Pair<U, V> b) {
            int cmpU = x.compareTo(b.x);
            return cmpU != 0 ? cmpU : y.compareTo(b.y);
        }

        public String toString() {
            return String.format("(%s, %s)", x.toString(), y.toString());
        }

    }
    static LinkedList<Integer> li[]=new LinkedList[100001];
    static int ans1=0,ans2=0,max1=-1;
    static int dist[]=new int[100001];
    static int visited[][];
    //static int arr[];
    static ArrayList<Integer> adj[];
    // static void bfs(int n,int m){
    //     //visited[x]=1;
    //     //visit[j]++;
    //     dist[n]=0;
    //     visited[n]=1;
    //     Queue<Integer> q=new LinkedList<>();
    //     q.add(n);
    //     while(!q.isEmpty()){
    //         int x=q.poll();
    //         for(int i=0;i<adj[x].size();i++){
    //             if(visited[adj[x].get(i)]==0){
    //                 q.add(adj[x].get(i));
    //                 visited[adj[x].get(i)]=1;
    //                 dist[adj[x].get(i)]=dist[x]+1;
    //             }
    //             if(adj[x].get(i)==m)
    //             {
    //                 return;
    //             }
    //         }
    //     }
    //     // for(int i=0;i<adj[x].size();i++){
    //     //     if(visited[adj[x].get(i)]==0){
    //     //         //check[j]++;
    //     //         ans1++;
    //     //         dfs(adj[x].get(i));
    //     //     }
    //     // }
    // }
    public static void main(String args[]){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
        int t,i,j;
        t=in.nextInt();
        while(t-->0){
            int n,k,b,c,d;
            n=in.nextInt();
            k=in.nextInt();
            int arr[]=new int[n];
            int pre[]=new int[n];
            for(i=0;i<n;i++){
                arr[i]=in.nextInt();
            }
            for(i=1;i<n-1;i++){
                if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
                    pre[i]++;
                }
            }
            for(i=1;i<n;i++){
                pre[i]+=pre[i-1];
                //w.print(pre[i]+" ");
            }
            for(i=n-1;i>=1;i--){
                if(pre[i]!=pre[i-1]){
                    pre[i]=pre[i-1];
                }
            }
            // for(i=0;i<n;i++){
            //     //pre[i+1]+=pre[i];
            //     w.print(pre[i]+" ");
            // }
            //w.println();
            int max=0,ind=0,diff=0;

            for(i=0;i<n-k+1;i++){
                diff=pre[i+k-1]-pre[i];
                if(max<diff){
                    max=diff;
                    ind=i+1;
                }
            }
            if(max==0){
                ind=1;
            }
            w.println((max+1)+" "+ind);
        }
        w.close();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
    public static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.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);
        }
    }

    static long gcd(long a, long b){
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    static long lcm(long a, long b)  {
        return (a*b)/gcd(a, b);
    }
    public static void sortbyColumn(int arr[][], int col)
    {

        Arrays.sort(arr, new Comparator<int[]>() {

          @Override

          public int compare(final int[] entry1,
                             final int[] entry2) {

            if (entry1[col] > entry2[col])
                return 1;
            else
                return -1;
          }
        });
    }
    static long func(long a[],long size,int s){
        long max1=a[s];
        long maxc=a[s];
        for(int i=s+1;i<size;i++){
            maxc=Math.max(a[i],maxc+a[i]);
            max1=Math.max(maxc,max1);
        }
        return max1;
    }
    public static class Pair<U extends Comparable<U>, V extends Comparable<V>> implements Comparable<Pair<U, V>> {
        public U x;
        public V y;

        public Pair(U x, V y) {
            this.x = x;
            this.y = y;
        }

        public int hashCode() {
            return (x == null ? 0 : x.hashCode() * 31) + (y == null ? 0 : y.hashCode());
        }

        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair<U, V> p = (Pair<U, V>) o;
            return (x == null ? p.x == null : x.equals(p.x)) && (y == null ? p.y == null : y.equals(p.y));
        }

        public int compareTo(Pair<U, V> b) {
            int cmpU = x.compareTo(b.x);
            return cmpU != 0 ? cmpU : y.compareTo(b.y);
        }

        public String toString() {
            return String.format("(%s, %s)", x.toString(), y.toString());
        }

    }
    static LinkedList<Integer> li[]=new LinkedList[100001];
    static int ans1=0,ans2=0,max1=-1;
    static int dist[]=new int[100001];
    static int visited[][];
    //static int arr[];
    static ArrayList<Integer> adj[];
    // static void bfs(int n,int m){
    //     //visited[x]=1;
    //     //visit[j]++;
    //     dist[n]=0;
    //     visited[n]=1;
    //     Queue<Integer> q=new LinkedList<>();
    //     q.add(n);
    //     while(!q.isEmpty()){
    //         int x=q.poll();
    //         for(int i=0;i<adj[x].size();i++){
    //             if(visited[adj[x].get(i)]==0){
    //                 q.add(adj[x].get(i));
    //                 visited[adj[x].get(i)]=1;
    //                 dist[adj[x].get(i)]=dist[x]+1;
    //             }
    //             if(adj[x].get(i)==m)
    //             {
    //                 return;
    //             }
    //         }
    //     }
    //     // for(int i=0;i<adj[x].size();i++){
    //     //     if(visited[adj[x].get(i)]==0){
    //     //         //check[j]++;
    //     //         ans1++;
    //     //         dfs(adj[x].get(i));
    //     //     }
    //     // }
    // }
    public static void main(String args[]){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter w = new PrintWriter(outputStream);
        int t,i,j;
        t=in.nextInt();
        while(t-->0){
            int n,k,b,c,d;
            n=in.nextInt();
            k=in.nextInt();
            int arr[]=new int[n];
            int pre[]=new int[n];
            for(i=0;i<n;i++){
                arr[i]=in.nextInt();
            }
            for(i=1;i<n-1;i++){
                if(arr[i]>arr[i-1]&&arr[i]>arr[i+1]){
                    pre[i]++;
                }
            }
            for(i=1;i<n;i++){
                pre[i]+=pre[i-1];
            }
            int max=0,ind=0,diff=0;
            for(i=n-1;i>=2;i--){
                if(pre[i]==pre[i-1]&&pre[i-1]!=pre[i-2]){
                    if(i-k+1>=0){

                        diff=pre[i]-pre[i-k+1];
                        //w.println(i+" "+diff);
                        if(max<=diff){
                            max=diff;
                            ind=i-k+2;
                        }
                    }else{
                        diff=pre[i]-pre[0];
                        if(max<=diff){
                            max=diff;
                            ind=1;
                        }
                    }

                }else if(i-k+1<0){
                    diff=pre[i]-pre[0];
                    if(max<=diff){
                        max=diff;
                        ind=1;
                    }
                }
            }
            w.println((max+1)+" "+ind);
        }
        w.close();
    }

}