#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() #define fix(x) fixed << setprecision(x) #define eb emplace_back constexpr char nl='\n'; using namespace std; using ll = long long; using ld = long double; using vl = vector; using vvl = vector>; using vs = vector; using pl = pair; template inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;} template inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;} templateusing rp_queue=priority_queue,greater>; void fast_io(){cin.tie(nullptr);ios_base::sync_with_stdio(false);} template T gcd(T a, T b) {if (b == 0)return a; else return gcd(b, a % b);} template inline T lcm(T a, T b) {return a /gcd(a, b)*b;} const ld PI = acos(-1); #include using S = long long; using F = long long; const S INF = 8e18; S op(S a, S b){ return std::max(a, b); } S e(){ return -INF; } S mapping(F f, S x){ return f+x; } F composition(F f, F g){ return f+g; } F id(){ return 0; } void solve(){ int N,M;cin>>N>>M; std::vector A(N+1); atcoder::lazy_segtree seg(A); //それぞれに何回マイナスその数がされたのかを求める配列 //imosでやる vl minus(N+2),plus(N+2); //これを区間加算を使って高速化する while(M--){ ll p,q;cin>>p>>q; for(int j=1;j<=N;j++){ if(p-j>=0)seg.set(j,seg.get(j)+max(0LL,q-p+j)); else seg.set(j,seg.get(j)+max(0LL,q+p-j)); } } vl ans(N+1); for(int i=1;i<=N;i++){ ans[i] = max(seg.get(i)+(plus[i]-minus[i])*i,0LL); cout<> num_tc; rep(tc,num_tc){ //cout << "Case #" << tc+1 << ": " ;// << endl; solve(); } }