//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
int f[222222], n, k, s, t, tmp;
struct _car{
    int c,v;
}car[222222];

int check(int fuel){
    int ans=0;
    for (int i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        if(fuel>=f[i] && fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
    }
    return ans<t;
}

int main(int argc, const char * argv[]) {
    cin>>n>>k>>s>>t;
    int l=2100600000,r=0;
    for (int i=0; i<n; i++) {
        cin>>car[i].c>>car[i].v;
        if (car[i].v>r) {
            r=car[i].v;
        }
        if (car[i].v<l) {
            l=car[i].v;
        }
    }
    for (int i=1; i<=k; i++) {
        cin>>f[i];
    }
    k++;
    sort(f, f+k);
    f[k]=s;
    s=0;
    for (int i=k; i>=1; i--) {
        f[i]-=f[i-1];
        if (s<f[i]) {
            s=f[i];
        }
    }
    if(s>l)l=s;
    int mid=(l+r)>>1,ans=-1;
    if (!check(r)||l>r) {
        cout<<-1<<endl;
    }
    else{
        while (l<=r) {
            if (check(mid)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        int cmin=2100060000;
        for (int i=0; i<n; i++) {
            if (car[i].v>=ans&&car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}
//using namespace std;
//const int N=2e5+20;
//typedef long long ll;
//ll s,T;//
//int n,k;
//int p[N];//the pos of gas station
//struct node{
//    ll c;
//    ll v;
//}a[N];
//bool cmp(node &x,node &y)// 按tank容量小到大排序
//{
//    return x.v<y.v;
//}
//bool check(int x)
//{
//    int cnt=0,pre=p[0];
//    for(int i=1;i<=k+1;i++)
//    {
//        int d=p[i]-pre;
//        if(d>a[x].v)
//            return false;//无法到达下一个gas station
//
//        //加油不要钱 不需要时间 到达一次肯定充满一次
//        int t=a[x].v/2;
//        if(d<=t)//有油 就加速
//            cnt+=d;
//        else
//        {
//            //为了最快,y为使用加速的时间,应该要最大
//            //2y+(d-y)<=v
//            int y=a[x].v-d;
//            cnt+=y+(d-y)*2;
//        }
//        pre=p[i];
//        if(cnt>T)
//            return false;
//    }
//    return true;
//}
//int main()
//{
//    cin>>n>>k>>s>>T;
//    for(int i=1;i<=n;i++)
//        scanf("%I64d%I64d",&a[i].c,&a[i].v);
//
//    for(int i=1;i<=k;i++)
//        scanf("%d",&p[i]);
//
//    p[0]=0;
//    p[k+1]=s;//起点终点方便起见也看作油站
//    sort(p,p+k+2);
//    sort(a+1,a+1+n,cmp);
//
//    int l=1,r=n;
//    int j=0;
//    //vi>vj 若使用vj能通过 vi也能通过 二分找到最小的vj 然后再j~n中选出c最小的即可
//    while(l<=r)
//    {
//        int mid=(l+r)/2;
//        if(check(mid))
//        {
//            j=mid;
//            r=mid-1;
//        }
//        else
//        {
//            l=mid+1;
//        }
//    }
//    if(!j)
//        cout<<-1<<endl;
//    else
//    {
//        ll ans=1e9;
//
//        for(;j<=n;j++)
//        {
//
//            ans=min(a[j].c,ans);
//        }
//        cout<<ans<<endl;
//    }
//    return 0;
//}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
int f[222222], n, k, s, t, tmp;
struct _car{
    int c,v;
}car[222222];
bool cheaper(_car a,_car b){
    return a.c<b.c;
}

int tmin(int fuel){
    int ans;
    for (int i=1; i<=k; i++){
        if (fuel<f[i]) {
            return 2100000000;
        }
        else if(fuel>=f[i] && fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
    }
    return ans;
}

int main(int argc, const char * argv[]) {
    cin>>n>>k>>s>>t;
    int l=2100000000,r=0;
    for (int i=0; i<n; i++) {
        cin>>car[i].c>>car[i].v;
        if (car[i].v>r) {
            r=car[i].v;
        }
        if (car[i].v<l) {
            l=car[i].v;
        }
    }
    for (int i=1; i<=k; i++) {
        cin>>f[i];
    }
    k++;
    sort(f, f+k);
    sort(car, car+n, cheaper);
    f[k]=s;
    for (int i=k; i>=2; i--) {
        f[i]-=f[i-1];
    }
    int mid=(l+r)>>1,ans=mid;
    if (tmin(r)>t) {
        cout<<-1<<endl;
    }
    else{
        while (l<r) {
            if (tmin(mid)<=t) {
                ans=mid;
                l=mid+1;
            }
            else{
                r=mid-1;
            }
        }
        for (int i=0; i<n; i++) {
            if (car[i].v>=ans) {
                cout<<car[i].c<<endl;
                break;
            }
        }
    }
    return 0;
}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
long long f[222222], n, k, s, t, tmp;
struct _car{
    long long c,v;
}car[222222];

bool cper(const _car &a,const _car &b){return a.v<b.v;}

long long check(long long fuel){
    long long ans=0;
    for (long long i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        else if(fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
        if (ans>t) {
            return false;
        }
    }
    return ans<=t;
}

int main(void) {
    cin>>n>>k>>s>>t;
    long long l=0,r=n-1;
    for (long long i=0; i<n; i++) {
        cin>>car[i].c>>car[i].v;
//        if (car[i].v>r) {
//            r=car[i].v;
//        }
//        if (car[i].v<l) {
//            l=car[i].v;
//        }
    }
    for (long long i=1; i<=k; i++) {
        cin>>f[i];
    }
    k++;
    sort(f, f+k);
    sort(car, car+n, cper);
    f[k]=s;
    s=0;
    for (long long i=k; i>=1; i--) {
        f[i]-=f[i-1];
//        if (s<f[i]) {
//            s=f[i];
//        }
    }
    //if(s>l)l=s;
    long long mid=(l+r)>>1,ans=-1;
    if (!check(car[r].v)||l>r) {
        cout<<-1<<endl;
    }
    else{
        ans=r;
        r--;
        while (l<=r) {
            if (check(car[mid].v)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        long long cmin=2100060000;
        for (long long i=ans; i<n; i++) {
            if (car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}
//using namespace std;
//const long long N=2e5+20;
//typedef long long ll;
//ll s,T;//
//long long n,k;
//long long p[N];//the pos of gas station
//struct node{
//    ll c;
//    ll v;
//}a[N];
//bool cmp(node &x,node &y)// 按tank容量小到大排序
//{
//    return x.v<y.v;
//}
//bool check(long long x)
//{
//    long long cnt=0,pre=p[0];
//    for(long long i=1;i<=k+1;i++)
//    {
//        long long d=p[i]-pre;
//        if(d>a[x].v)
//            return false;//无法到达下一个gas station
//
//        //加油不要钱 不需要时间 到达一次肯定充满一次
//        long long t=a[x].v/2;
//        if(d<=t)//有油 就加速
//            cnt+=d;
//        else
//        {
//            //为了最快,y为使用加速的时间,应该要最大
//            //2y+(d-y)<=v
//            long long y=a[x].v-d;
//            cnt+=y+(d-y)*2;
//        }
//        pre=p[i];
//        if(cnt>T)
//            return false;
//    }
//    return true;
//}
//long long main()
//{
//    cin>>n>>k>>s>>T;
//    for(long long i=1;i<=n;i++)
//        scanf("%I64d%I64d",&a[i].c,&a[i].v);
//
//    for(long long i=1;i<=k;i++)
//        scanf("%d",&p[i]);
//
//    p[0]=0;
//    p[k+1]=s;//起点终点方便起见也看作油站
//    sort(p,p+k+2);
//    sort(a+1,a+1+n,cmp);
//
//    long long l=1,r=n;
//    long long j=0;
//    //vi>vj 若使用vj能通过 vi也能通过 二分找到最小的vj 然后再j~n中选出c最小的即可
//    while(l<=r)
//    {
//        long long mid=(l+r)/2;
//        if(check(mid))
//        {
//            j=mid;
//            r=mid-1;
//        }
//        else
//        {
//            l=mid+1;
//        }
//    }
//    if(!j)
//        cout<<-1<<endl;
//    else
//    {
//        ll ans=1e9;
//
//        for(;j<=n;j++)
//        {
//
//            ans=min(a[j].c,ans);
//        }
//        cout<<ans<<endl;
//    }
//    return 0;
//}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
long long f[222222], n, k, s, t, tmp;
struct _car{
    long long c,v;
}car[222222];

bool cper(const _car &a,const _car &b){return a.v<b.v;}

long long check(long long fuel){
    long long ans=0;
    for (long long i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        else if(fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
        if (ans>t) {
            return false;
        }
    }
    return ans<=t;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin>>n>>k>>s>>t;
    long long l=0,r=n-1;
    for (long long i=0; i<n; i++) {
        scanf("%lld%lld",&car[i].c,&car[i].v);
//        if (car[i].v>r) {
//            r=car[i].v;
//        }
//        if (car[i].v<l) {
//            l=car[i].v;
//        }
    }
    for (long long i=1; i<=k; i++) {
        scanf("%lld",&f[i]);
    }
    k++;
    sort(f, f+k);
    sort(car, car+n, cper);
    f[k]=s;
    s=0;
    for (long long i=k; i>=1; i--) {
        f[i]-=f[i-1];
//        if (s<f[i]) {
//            s=f[i];
//        }
    }
    //if(s>l)l=s;
    //cout<<"start"<<endl;
    long long mid=(l+r)>>1,ans=-1;
    if (!check(car[r].v)||l>r) {
        cout<<-1<<endl;
    }
    else{
        ans=r;
        r--;
        while (l<=r) {
            if (check(car[mid].v)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        long long cmin=2100060000;
        for (long long i=ans; i<n; i++) {
            if (car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}
//using namespace std;
//const long long N=2e5+20;
//typedef long long ll;
//ll s,T;//
//long long n,k;
//long long p[N];//the pos of gas station
//struct node{
//    ll c;
//    ll v;
//}a[N];
//bool cmp(node &x,node &y)// 按tank容量小到大排序
//{
//    return x.v<y.v;
//}
//bool check(long long x)
//{
//    long long cnt=0,pre=p[0];
//    for(long long i=1;i<=k+1;i++)
//    {
//        long long d=p[i]-pre;
//        if(d>a[x].v)
//            return false;//无法到达下一个gas station
//
//        //加油不要钱 不需要时间 到达一次肯定充满一次
//        long long t=a[x].v/2;
//        if(d<=t)//有油 就加速
//            cnt+=d;
//        else
//        {
//            //为了最快,y为使用加速的时间,应该要最大
//            //2y+(d-y)<=v
//            long long y=a[x].v-d;
//            cnt+=y+(d-y)*2;
//        }
//        pre=p[i];
//        if(cnt>T)
//            return false;
//    }
//    return true;
//}
//long long main()
//{
//    cin>>n>>k>>s>>T;
//    for(long long i=1;i<=n;i++)
//        scanf("%I64d%I64d",&a[i].c,&a[i].v);
//
//    for(long long i=1;i<=k;i++)
//        scanf("%d",&p[i]);
//
//    p[0]=0;
//    p[k+1]=s;//起点终点方便起见也看作油站
//    sort(p,p+k+2);
//    sort(a+1,a+1+n,cmp);
//
//    long long l=1,r=n;
//    long long j=0;
//    //vi>vj 若使用vj能通过 vi也能通过 二分找到最小的vj 然后再j~n中选出c最小的即可
//    while(l<=r)
//    {
//        long long mid=(l+r)/2;
//        if(check(mid))
//        {
//            j=mid;
//            r=mid-1;
//        }
//        else
//        {
//            l=mid+1;
//        }
//    }
//    if(!j)
//        cout<<-1<<endl;
//    else
//    {
//        ll ans=1e9;
//
//        for(;j<=n;j++)
//        {
//
//            ans=min(a[j].c,ans);
//        }
//        cout<<ans<<endl;
//    }
//    return 0;
//}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
long long f[222222], n, k, s, t, tmp;
struct _car{
    long long c,v;
}car[222222];

bool cper(const _car &a,const _car &b){return a.v<b.v;}

long long check(long long fuel){
    long long ans=0;
    for (long long i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        else if(fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
        if (ans>t) {
            return false;
        }
    }
    return ans<=t;
}

int main(void) {
    //ios::sync_with_stdio(false);
    cin>>n>>k>>s>>t;
    long long l=0,r=n-1;
    for (long long i=0; i<n; i++) {
        scanf("%lld%lld",&car[i].c,&car[i].v);
//        if (car[i].v>r) {
//            r=car[i].v;
//        }
//        if (car[i].v<l) {
//            l=car[i].v;
//        }
    }
    for (long long i=1; i<=k; i++) {
        scanf("%lld",&f[i]);
    }
    k++;
    sort(f, f+k);
    sort(car, car+n, cper);
    f[k]=s;
    s=0;
    for (long long i=k; i>=1; i--) {
        f[i]-=f[i-1];
//        if (s<f[i]) {
//            s=f[i];
//        }
    }
    //if(s>l)l=s;
    //cout<<"start"<<endl;
    long long mid=(l+r)>>1,ans=-1;
    if (!check(car[r].v)||l>r) {
        cout<<-1<<endl;
    }
    else{
        ans=r;
        r--;
        while (l<=r) {
            if (check(car[mid].v)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        long long cmin=2100060000;
        for (long long i=ans; i<n; i++) {
            if (car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
long long f[222222], n, k, s, t, tmp;
struct _car{
    long long c,v;
}car[222222];

bool cper(const _car &a,const _car &b){return a.v<b.v;}

long long check(long long fuel){
    long long ans=0;
    for (long long i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        else if(fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
        if (ans>t) {
            return false;
        }
    }
    return ans<=t;
}

int main(void) {
    ios::sync_with_stdio(false);
    cin>>n>>k>>s>>t;
    long long l=0,r=n-1;
    for (long long i=0; i<n; i++) {
        scanf("%lld%lld",&car[i].c,&car[i].v);
//        if (car[i].v>r) {
//            r=car[i].v;
//        }
//        if (car[i].v<l) {
//            l=car[i].v;
//        }
    }
    for (long long i=1; i<=k; i++) {
        scanf("%lld",&f[i]);
    }
    k++;
    sort(f, f+k);
    sort(car, car+n, cper);
    f[k]=s;
    s=0;
    for (long long i=k; i>=1; i--) {
        f[i]-=f[i-1];
//        if (s<f[i]) {
//            s=f[i];
//        }
    }
    //if(s>l)l=s;
    //cout<<"start"<<endl;
    long long mid=(l+r)>>1,ans=-1;
    if (!check(car[r].v)||l>r) {
        cout<<-1<<endl;
    }
    else{
        ans=r;
        r--;
        while (l<=r) {
            if (check(car[mid].v)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        long long cmin=2100060000;
        for (long long i=ans; i<n; i++) {
            if (car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}


//
//  main.cpp
//  737A
//
//  Created by zya on 17/1/17.
//  Copyright © 2017年 zya. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;
long long f[222222], n, k, s, t, tmp;
struct _car{
    long long c,v;
}car[222222];

long long check(long long fuel){
    long long ans=0;
    for (long long i=1; i<=k; i++){
        if (fuel<f[i]) {
            return false;
        }
        if(fuel>=f[i] && fuel<2*f[i]){
            ans+=3*f[i]-fuel;
        }
        else{
            ans+=f[i];
        }
    }
    return ans<=t;
}

int main(void) {
    cin>>n>>k>>s>>t;
    long long l=2100600000,r=0;
    for (long long i=0; i<n; i++) {
        cin>>car[i].c>>car[i].v;
        if (car[i].v>r) {
            r=car[i].v;
        }
        if (car[i].v<l) {
            l=car[i].v;
        }
    }
    for (long long i=1; i<=k; i++) {
        cin>>f[i];
    }
    k++;
    sort(f, f+k);
    f[k]=s;
    s=0;
    for (long long i=k; i>=1; i--) {
        f[i]-=f[i-1];
        if (s<f[i]) {
            s=f[i];
        }
    }
    if(s>l)l=s;
    long long mid=(l+r)>>1,ans=-1;
    if (!check(r)||l>r) {
        cout<<-1<<endl;
    }
    else{
        ans=r;
        r--;
        while (l<=r) {
            if (check(mid)) {
                ans=mid;
                r=mid-1;
            }
            else{
                l=mid+1;
            }
            mid=(l+r)>>1;
        }
        long long cmin=2100060000;
        for (long long i=0; i<n; i++) {
            if (car[i].v>=ans&&car[i].c<cmin) {
                cmin=car[i].c;
            }
        }
        cout<<cmin<<endl;
    }
    return 0;
}
//using namespace std;
//const long long N=2e5+20;
//typedef long long ll;
//ll s,T;//
//long long n,k;
//long long p[N];//the pos of gas station
//struct node{
//    ll c;
//    ll v;
//}a[N];
//bool cmp(node &x,node &y)// 按tank容量小到大排序
//{
//    return x.v<y.v;
//}
//bool check(long long x)
//{
//    long long cnt=0,pre=p[0];
//    for(long long i=1;i<=k+1;i++)
//    {
//        long long d=p[i]-pre;
//        if(d>a[x].v)
//            return false;//无法到达下一个gas station
//
//        //加油不要钱 不需要时间 到达一次肯定充满一次
//        long long t=a[x].v/2;
//        if(d<=t)//有油 就加速
//            cnt+=d;
//        else
//        {
//            //为了最快,y为使用加速的时间,应该要最大
//            //2y+(d-y)<=v
//            long long y=a[x].v-d;
//            cnt+=y+(d-y)*2;
//        }
//        pre=p[i];
//        if(cnt>T)
//            return false;
//    }
//    return true;
//}
//long long main()
//{
//    cin>>n>>k>>s>>T;
//    for(long long i=1;i<=n;i++)
//        scanf("%I64d%I64d",&a[i].c,&a[i].v);
//
//    for(long long i=1;i<=k;i++)
//        scanf("%d",&p[i]);
//
//    p[0]=0;
//    p[k+1]=s;//起点终点方便起见也看作油站
//    sort(p,p+k+2);
//    sort(a+1,a+1+n,cmp);
//
//    long long l=1,r=n;
//    long long j=0;
//    //vi>vj 若使用vj能通过 vi也能通过 二分找到最小的vj 然后再j~n中选出c最小的即可
//    while(l<=r)
//    {
//        long long mid=(l+r)/2;
//        if(check(mid))
//        {
//            j=mid;
//            r=mid-1;
//        }
//        else
//        {
//            l=mid+1;
//        }
//    }
//    if(!j)
//        cout<<-1<<endl;
//    else
//    {
//        ll ans=1e9;
//
//        for(;j<=n;j++)
//        {
//
//            ans=min(a[j].c,ans);
//        }
//        cout<<ans<<endl;
//    }
//    return 0;
//}


#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <assert.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REPP(i,k,n) for(int i=k;i<=n;i++)
#define scan(d) scanf("%d",&d)
#define scann(n,m) scanf("%d%d",&n,&m)
#define mst(a,k)  memset(a,k,sizeof(a));
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define mod 1000000007
#define N 200005
#define M 15
#define fre  freopen("input.txt","r",stdin)
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
using namespace std;
struct no
{
   int c,v;
}no[N];
int n,k,s,t;
int num[N];
bool check(int x)
{
   LL cot = 0;
   if(x>t) return 0;
   REPP(i,0,k){
     if(x < num[i]) return 0;
     if(x >= 2 * num[i]) cot += num[i];
     else{
      cot += num[i] * 2;
      cot -= x - num[i];
     }
     if(cot > t) return 0;
   }
   return 1;
}

int main()
{
   scann(n,k); scann(s,t);
   REP(i,0,n) scann(no[i].c,no[i].v);
   REPP(i,1,k) scan(num[i]);
   num[k+1] = s;
   num[0] = 0;
   sort(num,num+k+2);
   REPP(i,0,k) num[i] = num[i+1] - num[i];
   if(s > t) return -1;
   int l = 0, r = t+2;
   while(l <= r){
      int mid = (l + r) >> 1;
      if(check(mid)) r = mid-1;
      else   l = mid + 1;
   }
   //cout<< r <<endl;
   int ans = INF;
   REP(i,0,n){
   if(no[i].v <= r) continue;
   ans = min(ans , no[i].c);
   }
   printf("%d",ans==INF?-1:ans);
}


#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <assert.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REPP(i,k,n) for(int i=k;i<=n;i++)
#define scan(d) scanf("%d",&d)
#define scann(n,m) scanf("%d%d",&n,&m)
#define mst(a,k)  memset(a,k,sizeof(a));
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define mod 1000000007
#define N 200005
#define M 15
#define fre  freopen("input.txt","r",stdin)
using namespace std;
struct no
{
   int c,v;
   bool friend operator <(no a,no b){
     if(a.c == b.c) return a.v < b.v;
     return a.c < b.c;
   }
}no[N];
int len[N];

int main()
{
   int n,k,s,t;
   scann(n,k);
   scann(s,t);
   int maxlen = 0;
   int failnum = 0;
   REP(i,0,n){
   scann(no[i].c,no[i].v);
   }
   sort(no,no+n);
   REPP(i,1,k) scan(len[i]);
   len[0] = 0;
   len[k+1] = s;
   if(t<s){
      printf("-1");
      return 0;
   }
   sort(len,len+k+1);

   REPP(i,1,k+1){
      len[i-1] = len[i] - len[i-1];
      maxlen = max(maxlen,len[i-1]);
   }

   int ans =INF;
   REP(i,0,n){
   if(maxlen > no[i].v) continue;
   if(no[i].v < failnum) continue;
   if(no[i].c > ans) continue;
   int cot = 0;
   REPP(j,0,k){
   if(no[i].v>=2*len[j]){
      cot+= len[j];
   }else{
   cot += 2 * len[j];
   cot -= no[i].v-len[j];
   }
   if(cot>t){
      break;
   }
   }
   if(cot>t){
         failnum = max(failnum,no[i].v);
         continue;
   }
   ans = no[i].c;
   break;
   }
   printf("%d\n",ans==INF?-1:ans);
}

/*bool mp[N][N];
int main()
{
   int n,m;
   scann(n,m);
   int ans=0;
   REPP(i,1,n) REPP(j,1,m) scan(mp[i][j]);

   REPP(i,1,m){
   bool flag = 0;
   int l ,r;
   int cnt1=0,cnt2=0,cnt=0;
   REPP(j,1,n){
   if(!mp[j][i]){
      cnt++;
      if(flag) cnt1++;
      continue;
   }
   if(mp[j][i] && !flag){
      l = r =j;
      flag =1;
   }else if(mp[j][i]){
      r = j;
      cnt2 = cnt;
   }
   }
   if(!flag) continue;
   else ans+=2*cnt-(l-1)-(n-r);
   }

   REPP(i,1,n){
   bool flag = 0;
   int l ,r;
   int cnt1=0,cnt2=0,cnt=0;
   REPP(j,1,m){
   if(!mp[i][j]){
      cnt++;
      if(flag) cnt1++;
      continue;
   }
   if(mp[i][j] && !flag){
      l = r =j;
      flag =1;
   }else if(mp[i][j]){
      cnt2 = cnt;
      r = j;
   }
   }
   if(!flag) continue;
   else ans+=2*cnt-(l-1)-(m-r);
}
printf("%d\n",ans);
}*/

/*char s[N],ans[N];
int main()
{
   int n;
   scan(n);
   scanf("%s",s);
   int len = 0;
   for(int i=0;i<n;i++){
   bool flag =0;
   if(i+2<n &&s[i] == 'o'&&s[i+1] == 'g' &&s[i+2] =='o'){
         flag = 1;
         ans[len++]='*';
         ans[len++]='*';
         ans[len++]='*';
         i+= 3;
         while(i+1<n&&s[i]=='g'&&s[i+1]=='o'){
           i+=2;
         }
   }else ans[len++]=s[i];
    if(flag) i--;
   }
   ans[len]=0;
   printf("%s",ans);
	return 0;
}*/


#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <assert.h>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define REPP(i,k,n) for(int i=k;i<=n;i++)
#define scan(d) scanf("%d",&d)
#define scann(n,m) scanf("%d%d",&n,&m)
#define mst(a,k)  memset(a,k,sizeof(a));
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define mod 1000000007
#define N 200005
#define M 15
#define fre  freopen("input.txt","r",stdin)
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
using namespace std;
struct no
{
   int c,v;
}no[N];
int n,k,s,t;
int num[N];
bool check(int x)
{
   LL cot = 0;
   if(x>t) return 0;
   REPP(i,0,k){
     if(x < num[i]) return 0;
     if(x >= 2 * num[i]) cot += num[i];
     else{
      cot += num[i] * 2;
      cot -= x - num[i];
     }
     if(cot > t) return 0;
   }
   return 1;
}

int main()
{
   scann(n,k); scann(s,t);
   REP(i,0,n) scann(no[i].c,no[i].v);
   REPP(i,1,k) scan(num[i]);
   num[k+1] = s;
   num[0] = 0;
   sort(num,num+k+2);
   REPP(i,0,k) num[i] = num[i+1] - num[i];
   if(s > t) {
      printf("-1");
      return 0;
   }
   int l = 0, r = t+2;
   while(l <= r){
      int mid = (l + r) >> 1;
      if(check(mid)) r = mid - 1;
      else   l = mid + 1;
   }
   //cout<< r <<endl;
   int ans = INF;
   REP(i,0,n){
   if(no[i].v <= r) continue;
   ans = min(ans , no[i].c);
   }
   printf("%d",ans==INF?-1:ans);
}


#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define cout2(x, y) cout << x << " " << y << endl
#define N 200005
#define INF (1LL<<40)

using namespace std;

long long canReach(long long cap, long long len){

	if(len > cap)return INF;
	if(cap >= 2 * len)return len;
	long long dis = 2 * len - cap;
	return 2 * dis + (len - dis);
}

pair<long long, long long>car[N];

int n, k, top = 0, x[N];
long long s, t;

bool puedo(int pos){

	long long timer = 0;
	for(int i = 1; i < top; i++){

		timer += canReach(car[pos].first, x[i] - x[i - 1]);
		if(timer > t)return false;

	}

	return true;
}

int mini[N];

int main(){

	cin >> n >> k >> s >> t;

	for(int i = 0; i < n; i++)
		scanf("%I64d%I64d", &car[i].second, &car[i].first);

	sort(car, car + n);
	x[top++] = 0;

	for(int i = 0; i < k; i++)scanf("%d", &x[top++]);

	x[top++] = s;
	sort(x , x + top);

	mini[n] = (1<<30);
	for(int i = n - 1; i >= 0; i--)mini[i] = min(mini[i + 1], int(car[i].second));

	int lo = 0, hi = n - 1, me;

	while(lo < hi){

		me = lo + (hi - lo)/2;
		if(puedo(me))hi = me;
		else lo = me + 1;
	}

	//for(int i = 0; i < n; i++)cout << car[i].first << " " << car[i].second << endl;

	if(puedo(lo))cout << mini[lo] << endl;
	else puts("-1");

}


#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define cout2(x, y) cout << x << " " << y << endl
#define N 200005
#define INF (1LL<<40)

using namespace std;

long long canReach(long long cap, long long len){

	if(len >= cap)return INF;
	if(cap >= 2 * len)return len;
	long long dis = 2 * len - cap;
	return 2 * dis + (len - dis);
}

pair<long long, long long>car[N];

int n, k, top = 0, x[N];
long long s, t;

bool puedo(int pos){

	long long timer = 0;
	for(int i = 1; i < top; i++){

		timer += canReach(car[pos].first, x[i] - x[i - 1]);
		if(timer > t)return false;

	}

	return true;
}

int mini[N];

int main(){

	cin >> n >>k >> s >> t;

	for(int i = 0; i < n; i++)
		scanf("%I64d%I64d", &car[i].second, &car[i].first);

	sort(car, car + n);
	x[top++] = 0;

	for(int i = 0; i < k; i++)scanf("%d", &x[top++]);

	x[top++] = s;
	sort(x , x + top);

	mini[n] = (1<<30);
	for(int i = n - 1; i >= 0; i--)mini[i] = min(mini[i + 1], int(car[i].second));

	int lo = 0, hi = n - 1, me;

	while(lo < hi){

		me = lo + (hi - lo)/2;
		if(puedo(me))hi = me;
		else lo = me + 1;
	}

	//for(int i = 0; i < n; i++)cout << car[i].first << " " << car[i].second << endl;

	if(puedo(lo))cout << mini[lo] << endl;
	else puts("-1");

}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5*5;
typedef long long ll;
struct node
{
	int c,v;
}sv[MAXN];
bool cmp1(const node &a,const node &b)
{
	return a.v<b.v;
}
bool cmp2(const node &a,const node &b)
{
	return a.c<b.c;
}
int g[MAXN];
ll n,k,s,t;
bool judge(ll v)
{
	ll tot=0,tmp;
	for(int i=k;i>=1;i--)
	{
		tmp=v;
		ll dis=g[i]-g[i-1];
		if(dis>v)
			return false;
		tmp-=dis;
		tot+=2*dis;
		tot-=min(tmp,dis);
	}
	return tot<=t;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	scanf("%lld%lld%lld%lld",&n,&k,&s,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&sv[i].c,&sv[i].v);
	}
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&g[i]);
	}
	k++;
	g[0]=0,g[k]=s;
	sort(g+1,g+1+k);
	ll l=0,r=1e9+7,ans=1e9+7;
	while(l<=r)
	{
		ll m=(l+r)>>1;
		if(judge(m))
		{
			ans=min(ans,m);
			r=m-1;
		}
		else
		{
			l=m+1;
		}
	}
	node T;
	T.c=0,T.v=ans;
//	cout<<ans<<endl;
	sort(sv+1,sv+1+n,cmp1);
	int pos=lower_bound(sv+1,sv+1+n,T,cmp1)-sv;
	sort(sv+pos,sv+1+n,cmp2);
	if(pos==n+1)
		return 0*printf("-1\n");
	printf("%d\n",sv[pos].c);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5*5;
typedef long long ll;
struct node
{
	int c,v;
	bool operator < (const node &a)const
	{
		if(v==a.v)
			return c<a.c;
		return v<a.v;
	}
}sv[MAXN];
int g[MAXN];
ll n,k,s,t;
bool judge(ll v)
{
	ll tot=0,tmp;
	for(int i=k;i>=1;i--)
	{
		tmp=v;
		ll dis=g[i]-g[i-1];
		if(dis>v)
			return false;
		tmp-=dis;
		tot+=2*dis;
		tot-=min(tmp,dis);
	}
	return tot<=t;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	scanf("%lld%lld%lld%lld",&n,&k,&s,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&sv[i].c,&sv[i].v);
	}
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&g[i]);
	}
	k++;
	g[0]=0,g[k]=s;
	sort(g+1,g+1+k);
	sort(sv+1,sv+1+n);
	ll l=0,r=1e9+7,ans=1e9+7;
	while(l<=r)
	{
		ll m=(l+r)>>1;
		if(judge(m))
		{
			ans=min(ans,m);
			r=m-1;
		}
		else
		{
			l=m+1;
		}
	}
	node t;
	t.c=0,t.v=ans;
//	cout<<ans<<endl;
	int pos=lower_bound(sv+1,sv+1+n,t)-sv;
	if(pos==n+1)
		return 0*printf("-1\n");
	printf("%d\n",sv[pos].c);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5*5;
typedef long long ll;
struct node
{
	int c,v;
	bool operator < (const node &a)const
	{
		if(v==a.v)
			return c<a.c;
		return v<a.v;
	}
}sv[MAXN];
int g[MAXN];
ll n,k,s,t;
bool judge(int v)
{
	ll tot=0,tmp;
	for(int i=k;i>=1;i--)
	{
		tmp=v;
		ll dis=g[i]-g[i-1];
		if(dis>v)
			return false;
		tmp-=dis;
		tot+=2*dis;
		tot-=min(tmp,dis);
	}
	return tot<=t;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	scanf("%lld%lld%lld%lld",&n,&k,&s,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&sv[i].c,&sv[i].v);
	}
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&g[i]);
	}
	k++;
	g[k]=s;
	sort(g+1,g+1+k);
	sort(sv+1,sv+1+n);
	int l=0,r=1e9+7,ans=1e9+7;
	while(l<=r)
	{
		int m=(l+r)>>1;
		if(judge(m))
		{
			ans=min(ans,m);
			r=m-1;
		}
		else
		{
			l=m+1;
		}
	}
	node t;
	t.c=0,t.v=ans;
//	cout<<ans<<endl;
	int pos=lower_bound(sv+1,sv+1+n,t)-sv;
	if(pos==n+1)
		return 0*printf("-1\n");
	printf("%d\n",sv[pos].c);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5*5;
typedef long long ll;
struct node
{
	int c,v;
	bool operator < (const node &a)const
	{
		if(v==a.v)
			return c<a.c;
		return v<a.v;
	}
}sv[MAXN];
int g[MAXN];
ll n,k,s,t;
bool judge(ll v)
{
	ll tot=0,tmp;
	for(int i=k;i>=1;i--)
	{
		tmp=v;
		ll dis=g[i]-g[i-1];
		if(dis>v)
			return false;
		tmp-=dis;
		tot+=2*dis;
		tot-=min(tmp,dis);
	}
	return tot<=t;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	scanf("%lld%lld%lld%lld",&n,&k,&s,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&sv[i].c,&sv[i].v);
	}
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&g[i]);
	}
	k++;
	g[0]=0,g[k]=s;
	sort(g+1,g+1+k);
	sort(sv+1,sv+1+n);
	ll l=0,r=1e9+7,ans=1e9+7;
	while(l<=r)
	{
		ll m=(l+r)>>1;
		if(judge(m))
		{
			ans=min(ans,m);
			r=m-1;
		}
		else
		{
			l=m+1;
		}
	}
	node T;
	T.c=0,T.v=ans;
//	cout<<ans<<endl;
	int pos=lower_bound(sv+1,sv+1+n,T)-sv;
	if(pos==n+1)
		return 0*printf("-1\n");
	printf("%d\n",sv[pos].c);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void cruiser() {
	int mx_neg = INT_MIN;
	int n,m;
	cin>>n>>m;
	int ans=0,x;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			cin>>x;
			if(x<0) mx_neg=max(mx_neg,x);
			ans+=abs(x);
		}
	}
	if(mx_neg>INT_MIN) {
		ans-=2*abs(mx_neg);
	}
	cout<<ans<<"\n";
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		cruiser();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void cruiser() {
	int mx_neg = INT_MIN,cnt_neg=0,cnt_zero=0;
	int n,m;
	cin>>n>>m;
	int ans=0,x;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			cin>>x;
			if(x<0) {
				mx_neg=max(mx_neg,x);
				cnt_neg++;
			}
            if(x==0)cnt_zero++;
			ans+=abs(x);
		}
	}
	if(cnt_neg%2 && !cnt_zero) {
		ans-=2*abs(mx_neg);
	}
	cout<<ans<<"\n";
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		cruiser();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void cruiser() {
	int mx_neg = INT_MIN,cnt_neg=0;
	int n,m;
	cin>>n>>m;
	int ans=0,x;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			cin>>x;
			if(x<=0) {
				mx_neg=max(mx_neg,x);
				cnt_neg++;
			}
			ans+=abs(x);
		}
	}
	if(cnt_neg%2 && !cnt_zero) {
		ans-=2*abs(mx_neg);
	}
	cout<<ans<<"\n";
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		cruiser();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void cruiser() {
	int mx_neg = INT_MAX,cnt_neg=0;
	int n,m;
	cin>>n>>m;
	int ans=0,x;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			cin>>x;
			if(x<=0) {
                x=-x;
				cnt_neg++;
			}
            mx_neg=min(mx_neg,x);
			ans+=x;
		}
	}
	if(cnt_neg%2) {
		ans-=2*mx_neg;
	}
	cout<<ans<<"\n";
}
int main() {
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	int t;
	cin>>t;
	while(t--) {
		cruiser();
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void cruiser() {
	int mx_neg = INT_MIN,cnt_neg=0;
	int n,m;
	cin>>n>>m;
	int ans=0,x;
	for(int i=0;i<n;++i) {
		for(int j=0;j<m;++j) {
			cin>>x;
			if(x<0) {
				mx_neg=max(mx_neg,x);
				cnt_neg++;
			}
			ans+=abs(x);
		}
	}
	if(cnt_neg%2) {
		ans-=2*abs(mx_neg);
	}
	cout<<ans<<"\n";
}
int main() {
	int t;
	cin>>t;
	while(t--) {
		cruiser();
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define forn(i, a, b) for(int i = a; i < (b); i++)
#define forn_r(i, a, b) for(int i = (b) - 1; i >= a; i--)
#define forl(i, a, b) for(ll i = a; i < (b); i++)
#define forl_r(i, a, b) for(ll i = (b) - 1; i >= a; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define pA(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')
#define ppA(arr, len) for(int i = 0; i < len; i++) cout << arr[i].f << ' ' << arr[i].s <<  '\n'

const int INF = INT_MAX;
const ll LLNF = LLONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

const int lim = (int) 1e9 + 1;

void test_case() {
	int n, m;
	cin >> n >> m;

	int a[n * m];
	ll sum = 0;
	int cnt = 0;
	forn(i, 0, n * m) {
		cin >> a[i];
		if(a[i] < 0) cnt++;

		a[i] = abs(a[i]);
		sum += a[i];
	}

	sort(a, a + n);

	if(cnt % 2) sum -= a[0] * 2;

	cout << sum << '\n';
	return;
}

int main() {
	// cout << std::fixed << std::showpoint;
	// cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define forn(i, a, b) for(int i = a; i < (b); i++)
#define forn_r(i, a, b) for(int i = (b) - 1; i >= a; i--)
#define forl(i, a, b) for(ll i = a; i < (b); i++)
#define forl_r(i, a, b) for(ll i = (b) - 1; i >= a; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define pA(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')
#define ppA(arr, len) for(int i = 0; i < len; i++) cout << arr[i].f << ' ' << arr[i].s <<  '\n'

const int INF = INT_MAX;
const ll LLNF = LLONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

const int lim = (int) 1e9 + 1;

void test_case() {
	int n, m;
	cin >> n >> m;

	int a[n * m];
	ll sum = 0;
	bool f = false;
	forn(i, 0, n * m) {
		cin >> a[i];
		if(a[i] < 0) f = true;
		a[i] = abs(a[i]);
		sum += a[i];
	}

	sort(a, a + n);

	if(f) sum -= a[0] * 2;

	cout << sum << '\n';
	return;
}

int main() {
	// cout << std::fixed << std::showpoint;
	// cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define forn(i, a, b) for(int i = a; i < (b); i++)
#define forn_r(i, a, b) for(int i = (b) - 1; i >= a; i--)
#define forl(i, a, b) for(ll i = a; i < (b); i++)
#define forl_r(i, a, b) for(ll i = (b) - 1; i >= a; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define pA(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')
#define ppA(arr, len) for(int i = 0; i < len; i++) cout << arr[i].f << ' ' << arr[i].s <<  '\n'

const int INF = INT_MAX;
const ll LLNF = LLONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

const int lim = (int) 1e9 + 1;

void test_case() {
	int n, m;
	cin >> n >> m;

	int a[n * m];
	int sum = 0;
	forn(i, 0, n * m) {
		cin >> a[i];
		a[i] = abs(a[i]);
		sum += a[i];
	}

	sort(a, a + n);

	cout << sum - a[0] << '\n';
	return;
}

int main() {
	// cout << std::fixed << std::showpoint;
	// cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define forn(i, a, b) for(int i = a; i < (b); i++)
#define forn_r(i, a, b) for(int i = (b) - 1; i >= a; i--)
#define forl(i, a, b) for(ll i = a; i < (b); i++)
#define forl_r(i, a, b) for(ll i = (b) - 1; i >= a; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define pA(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')
#define ppA(arr, len) for(int i = 0; i < len; i++) cout << arr[i].f << ' ' << arr[i].s <<  '\n'

const int INF = INT_MAX;
const ll LLNF = LLONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

const int lim = (int) 1e9 + 1;

void test_case() {
	int n, m;
	cin >> n >> m;

	int a[n * m];
	int sum = 0;
	forn(i, 0, n * m) {
		cin >> a[i];
		a[i] = abs(a[i]);
		sum += a[i];
	}

	sort(a, a + n);

	cout << sum - a[0] * 2 << '\n';
	return;
}

int main() {
	// cout << std::fixed << std::showpoint;
	// cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

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

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define forn(i, a, b) for(int i = a; i < (b); i++)
#define forn_r(i, a, b) for(int i = (b) - 1; i >= a; i--)
#define forl(i, a, b) for(ll i = a; i < (b); i++)
#define forl_r(i, a, b) for(ll i = (b) - 1; i >= a; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>

#define debug(x) cout << #x << "=" << x << '\n'
#define debug2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << '\n'
#define print(x) cout << x << '\n'
#define print2(x, y) cout << x << ' ' << y << '\n'
#define pA(arr, len) for(int i = 0; i < len; i++) cout << arr[i] << (i == len - 1 ? '\n' : ' ')
#define ppA(arr, len) for(int i = 0; i < len; i++) cout << arr[i].f << ' ' << arr[i].s <<  '\n'

const int INF = INT_MAX;
const ll LLNF = LLONG_MAX;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }

const int lim = (int) 1e9 + 1;

void test_case() {
	int n, m;
	cin >> n >> m;

	int a[n * m];
	int sum = 0;
	int cnt = 0;
	forn(i, 0, n * m) {
		cin >> a[i];
		if(a[i] < 0) cnt++;

		a[i] = abs(a[i]);
		sum += a[i];
	}

	sort(a, a + n * m);

	if(cnt % 2) sum -= a[0] * 2;

	cout << sum << '\n';
	return;
}

int main() {
	// cout << std::fixed << std::showpoint;
	// cout << std::setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

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

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define ull unsigned long long
using namespace std;
int n,m, t,x, total=0, negativos=0;
int minimo = 999999;
bool neg = false;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for(int i=0; i<t; ++i){
        total = 0;
        minimo = 999999;
        neg = false;
        cin >> n >> m;
        for(int n1 =0; n1 < n; ++n1){
            for(int m1 =0; m1 < m; ++m1){
                cin >> x;
                total += abs(x);
                if(x<0){
                    neg = true;
                    //negativos++;
                }
                if(abs(x) < minimo){
                    minimo = abs(x);
                }

            }
        }
        if(neg){
            cout << total - 2*minimo << endl;
        }else{
            cout << total << endl;
        }

    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define ull unsigned long long
using namespace std;
int n,m, t,x, total=0;
int minimo = 999999;
vector<int> posi;
vector<int> neg;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for(int i=0; i<t; ++i){
        cin >> n >> m;

        for(int n1 =0; n1 < n; ++n1){
            for(int m1 =0; m1 < m; ++m1){
                cin >> x;
                total += abs(x);
                if(abs(x) < minimo){
                    minimo = abs(x);
                }

            }
        }
        cout << total - 2*minimo << endl;
        total =0;
        minimo = 999999;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define ull unsigned long long
using namespace std;
int n,m, t,x, total=0, negs=0;
int minimo = 999999;
bool neg = false;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for(int i=0; i<t; ++i){
        total = 0;
        minimo = 999999;
        neg = false;
        cin >> n >> m;
        for(int n1 =0; n1 < n; ++n1){
            for(int m1 =0; m1 < m; ++m1){
                cin >> x;
                total += abs(x);
                if(x<0){
                    neg = true;
                    negs++;
                }
                if(abs(x) < minimo){
                    minimo = abs(x);
                }

            }
        }

        if(neg){
            if(negs % 2 ==0){
                cout << total << endl;
            }else{
                cout << total - 2*minimo << endl;
            }
        }else{
            cout << total << endl;
        }

    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define ull unsigned long long
using namespace std;
int n,m, t,x, total=0;
int minimo = 999999;
bool neg = false;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for(int i=0; i<t; ++i){
        cin >> n >> m;

        for(int n1 =0; n1 < n; ++n1){
            for(int m1 =0; m1 < m; ++m1){
                cin >> x;
                total += abs(x);
                if(x<0){
                    neg = true;
                }
                if(abs(x) < minimo){
                    minimo = abs(x);
                }

            }
        }
        if(neg){
            cout << total - 2*minimo << endl;
        }else{
            cout << total << endl;
        }

        total =0;
        minimo = 999999;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define ull unsigned long long
using namespace std;
int n,m, t,x, total=0, negs=0;
int minimo = 999999;
bool neg = false;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> t;

    for(int i=0; i<t; ++i){
        total = 0;
        minimo = 999999;
        neg = false;
        negs = 0;
        cin >> n >> m;
        for(int n1 =0; n1 < n; ++n1){
            for(int m1 =0; m1 < m; ++m1){
                cin >> x;
                total += abs(x);
                if(x<0){
                    neg = true;
                    negs++;
                }
                if(abs(x) < minimo){
                    minimo = abs(x);
                }

            }
        }

        if(neg){
            if(negs % 2 ==0){
                cout << total << endl;
            }else{
                cout << total - 2*minimo << endl;
            }
        }else{
            cout << total << endl;
        }

    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];
       ll  maxSum=0,flag=0;
       vector<ll>res;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
              if(a[i][j]<0)
              {
                     res.push_back(a[i][j]);
              }
              else if(a[i][j]==0)
              {
                  flag=1;
              }
              else
              {
                  maxSum    +=  a[i][j];
              }

            }
        }
        sort(res.begin(),res.end());
        if(     flag==1 )
        {

                 for(ll i=0;i<res.size();i++)
                {
                    maxSum  +=  abs(res[i]);
                }

        }
         else if( (res.size())%2==0 )
            {
                 for(ll i=0;i<res.size();i++)
                {
                    maxSum  +=  abs(res[i]);
                }
            }
        else  if( (res.size())%2==1 )
        {
             for(ll i=0;i<res.size()-1;i++)
            {
                maxSum  +=  abs(res[i]);
            }
             maxSum  +=  res[res.size()-1];
        }

        // for(ll i=0;i<n;i++)
        // {
        //     for(ll j=0;j<m;j++)
        //     {
        //         maxSum      +=      a[i][j];
        //         //cout<<a[i][j]<<" ";
        //     }
        //     //cout<<"\n";
        // }
         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
            }
        }

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }
         for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }

         for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }

         for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }
    ll  maxSum=0;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                maxSum      +=      a[i][j];
                //cout<<a[i][j]<<" ";
            }
            //cout<<"\n";
        }
         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
            }
        }

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                    lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                          lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                           lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                              lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }

    ll  maxSum=0;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                maxSum      +=      a[i][j];
                //cout<<a[i][j]<<" ";
            }
            //cout<<"\n";
        }
         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];
       ll  maxSum=0;
       vector<ll>res;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
              if(a[i][j]<=0)
              {
                     res.push_back(a[i][j]);
              }
              else
              {
                  maxSum    +=  a[i][j];
              }

            }
        }
        sort(res.begin(),res.end());
        if((res.size())%2==0)
        {
            for(ll i=0;i<res.size();i++)
            {
                maxSum  +=  abs(res[i]);
            }
        }
        else
        {
             for(ll i=0;i<res.size()-1;i++)
            {
                maxSum  +=  abs(res[i]);
            }
             maxSum  +=  res[res.size()-1];
        }

        // for(ll i=0;i<n;i++)
        // {
        //     for(ll j=0;j<m;j++)
        //     {
        //         maxSum      +=      a[i][j];
        //         //cout<<a[i][j]<<" ";
        //     }
        //     //cout<<"\n";
        // }
         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
            }
        }

        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }
         for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                if(a[i][j]<=0)
                {
                    ll lt=i,rt=j,min1=LONG_MAX;
                     ll  temp    =   abs(a[i][j] );
                    if((i-1) >= 0)
                    {
                        if(a[i-1][j] < min1 )
                        {        min1    =   a[i-1][j];
                                  lt  =   i-1;    rt = j;
                        }

                    }
                    if((i+1) < n)
                    {
                        if(a[i+1][j] < min1 )
                         {       min1    =   a[i+1][j];
                                  lt  =   i+1;  rt = j;
                        }
                    }
                    if((j-1) >= 0)
                    {
                        if(a[i][j-1] < min1 )
                           {     min1    =   a[i][j-1];
                                  lt  =   i;   rt = j-1;
                        }

                    }
                    if((j+1) < m)
                    {
                        if(a[i][j+1] < min1 )
                            {    min1    =   a[i][j+1];
                                  lt  =   i;    rt = j+1;
                        }
                    }

                    if(a[lt][rt]<=0)
                    {
                              a[i][j] =   - a[i][j];
                              a[lt][rt] =   -a[lt][rt];
                    }
                    else if(a[lt][rt]>0)
                    {
                             if(a[lt][rt] <  abs(a[i][j]) )
                             {
                                a[i][j] =   - a[i][j];
                                a[lt][rt] =   -a[lt][rt];
                             }
                    }
                }

            }
        }
    ll  maxSum=0;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
                maxSum      +=      a[i][j];
                //cout<<a[i][j]<<" ";
            }
            //cout<<"\n";
        }
         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define iAmInevitable ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAXN   1000005

//map<ll,ll> totalFreq;
//vector<bool>visited;
//map<ll,ll> :: iterator itr;
//for(itr=freq.begin();itr!=freq.end();itr++)
//itr->f    itr->s

int main()
{
   iAmInevitable;
   int t;
   cin>>t;
   while(t--)
   {
       ll  n,m;
       cin>>n>>m;
       ll   a[n][m];
       ll  maxSum=0,flag=0;
       vector<ll>res,totalVec;
        for(ll i=0;i<n;i++)
        {
            for(ll j=0;j<m;j++)
            {
              cin>>a[i][j];
              totalVec.push_back(abs(a[i][j]));
              if(a[i][j]<0)
              {
                     res.push_back(a[i][j]);
              }
              else if(a[i][j]==0)
              {
                  flag=1;
              }

            }
        }
        sort(totalVec.begin(),totalVec.end());
        if(     flag==1 )
        {

                 for(ll i=0;i<totalVec.size();i++)
                {
                    maxSum    +=  totalVec[i];
                }

        }
         else if( (res.size())%2==0 )
            {
                for(ll i=0;i<totalVec.size();i++)
                {
                    maxSum    +=  totalVec[i];
                }
            }
        else  if( (res.size())%2==1 )
        {
              for(ll i=1;i<totalVec.size();i++)
                {
                    maxSum    +=  totalVec[i];
                }
             maxSum  -=  totalVec[0];
        }

         cout<<maxSum<<"\n";
   }
return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{

    int n,m;
    cin >> n >> m;
   int a[n][m];
    int cnt = 0;
    int sum = 0, sum2 = 0;
    int mn=INF;
    fr(i, n)
    {
        fr(j, m)
        {

            cin >> a[i][j];
           mn= min(mn,abs(a[i][j]));
             if(a[i][j]<0)cnt++;

        }
    }
    bool flag=0;
    fr(x, n)
    {
        fr(y, m)
        {
            if(a[x][y]==0)
            {
                flag=1;
            }
        }
    }
    int ans=0;
    fr(i,n)
    {
        fr(j,m)
        {
            ans+=abs(a[i][j]);
            sum+=a[i][j];

        }
        // cout<<"\n";
    }
    if(flag==1)
    {
        cout<<ans<<"\n";
    }
    else
    {
        if(cnt % 2==0)
        {
            cout<<ans<<"\n";

        }
        else
        {

          cout<<ans-2*abs(mn)<<"\n";
        }
    }

    // cout<<ans<<"\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n, m;
bool isValid(int x, int y)
{
    if (x < 0 || x > n - 1 || y < 0 || y > m - 1)
        return 0;
    // if (vis[x][y] == 1)
    //     return 0;
    return 1;
}
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void solve()
{

    cin >> n >> m;
    int a[n][m];
    int cnt = 0;
    int sum = 0, sum2 = 0;
    fr(i, n)
    {
        fr(j, m)
        {
            cin >> a[i][j];
            if(a[i][j]<0)cnt++;
        }
    }
    bool flag=0;
    fr(x, n)
    {
        fr(y, m)
        {
            if(a[x][y]==0)
            {
            for (int i = 0; i < 4; i++)
            {
                int newx = x + dx[i], newy = y + dy[i];
                if (isValid(newx, newy))
                {
                   if(a[newx][newy]<0)
                   flag=1;
                }
            }
            }
        }
    }
    int ans=0;
    fr(i,n)
    {
        fr(j,m)
        {
            ans+=abs(a[i][j]);
            sum+=a[i][j];
        }
        // cout<<"\n";
    }
    if(flag==1)
    {
        cout<<ans<<"\n";
    }
    else
    {
        if(cnt % 2==0)
        {
            cout<<ans<<"\n";
        }
        else
        {
            cout<<sum<<"\n";
        }
    }

    // cout<<ans<<"\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{

    int n,m;
    cin >> n >> m;
   int a[n][m];
    int cnt = 0;
    int sum = 0, sum2 = 0;
    int mn=INT_MAX;
    fr(i, n)
    {
        fr(j, m)
        {
            cin >> a[i][j];
            if(a[i][j]<0)cnt++;

        }
    }
    bool flag=0;
    fr(x, n)
    {
        fr(y, m)
        {
            if(a[x][y]==0)
            {
                flag=1;
            }
        }
    }
    int ans=0;
    fr(i,n)
    {
        fr(j,m)
        {
            ans+=abs(a[i][j]);
            sum+=a[i][j];
            mn=  min(mn,a[i][j]);
        }
        // cout<<"\n";
    }
    if(flag==1)
    {
        cout<<ans<<"\n";
    }
    else
    {
        if(cnt % 2==0)
        {
            cout<<ans<<"\n";
        }
        else
        {

          cout<<ans-2*abs(mn)<<"\n";
        }
    }

    // cout<<ans<<"\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{

    int n,m;
    cin >> n >> m;
   int a[n][m];
    int cnt = 0;
    int sum = 0, sum2 = 0;
    int mn=-INF;
    fr(i, n)
    {
        fr(j, m)
        {
            cin >> a[i][j];
            if(a[i][j]<0){
                cnt++;
                mn= max(mn,a[i][j]);
            }

        }
    }
    bool flag=0;
    fr(x, n)
    {
        fr(y, m)
        {
            if(a[x][y]==0)
            {
                flag=1;
            }
        }
    }
    int ans=0;
    fr(i,n)
    {
        fr(j,m)
        {
            ans+=abs(a[i][j]);
            sum+=a[i][j];

        }
        // cout<<"\n";
    }
    if(flag==1)
    {
        cout<<ans<<"\n";
    }
    else
    {
        if(cnt % 2==0)
        {
            cout<<ans<<"\n";
        }
        else
        {

          cout<<ans-2*abs(mn)<<"\n";
        }
    }

    // cout<<ans<<"\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n][m];
    int cnt=0;
    int sum=0,sum2=0;
    fr(i,n)
    {
        fr(j,m)
        {
            cin>>a[i][j];
            if(a[i][j]<=0)cnt++;
            sum+=a[i][j];
            sum2+=abs(a[i][j]);
        }

    }
    if(cnt %2==0 )
    {
        cout<<sum2<<"\n";
    }
    else
    {
        cout<<sum<<"\n";
    }

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int n, m;
bool isValid(int x, int y)
{
    if (x < 0 || x > n - 1 || y < 0 || y > m - 1)
        return 0;
    // if (vis[x][y] == 1)
    //     return 0;
    return 1;
}
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void solve()
{

    cin >> n >> m;
    int a[n][m];
    int cnt = 0;
    int sum = 0, sum2 = 0;
    fr(i, n)
    {
        fr(j, m)
        {
            cin >> a[i][j];
            if(a[i][j]<0)cnt++;
        }
    }
    bool flag=0;
    fr(x, n)
    {
        fr(y, m)
        {
            if(a[x][y]==0)
            {
                flag=1;
            }
        }
    }
    int ans=0;
    fr(i,n)
    {
        fr(j,m)
        {
            ans+=abs(a[i][j]);
            sum+=a[i][j];
        }
        // cout<<"\n";
    }
    if(flag==1)
    {
        cout<<ans<<"\n";
    }
    else
    {
        if(cnt % 2==0)
        {
            cout<<ans<<"\n";
        }
        else
        {
            cout<<sum<<"\n";
        }
    }

    // cout<<ans<<"\n";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define all(x) (x).begin(), x.end()
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n][m];
    int cnt=0;
    int sum=0,sum2=0;
    fr(i,n)
    {
        fr(j,m)
        {
            cin>>a[i][j];
            if(a[i][j]<0)cnt++;
            sum+=a[i][j];
            sum2+=abs(a[i][j]);
        }

    }
    if(cnt >=2)
    {
        cout<<sum2<<"\n";
    }
    else
    {
        cout<<sum<<"\n";
    }

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    // t = 1;
    cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case #" << k++ << ": ";
        solve();
    }
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        vector<int> freq(102,0);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
            }
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                sum+=abs(a[i][j]);
                if(a[i][j]==0){
                    freq[0]++;
                }
                if(a[i][j]<0){
                    freq[abs(a[i][j])]++;
                    count++;
                }
            }
        }

        if((count%2)==0 || freq[0]>0){
            cout<<sum<<'\n';
        }else{
            for(int i=1; i<=100; i++){
                if(freq[i]>0){
                    sum-=(2*i);
                    break;
                }
            }
            cout<<sum<<'\n';
        }

    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        vector<int> freq(102,0);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
            }
        }

        int low = 100;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                sum+=abs(a[i][j]);
                if(a[i][j]==0){
                    freq[0]++;
                }
                if(a[i][j]<0){
                    freq[abs(a[i][j])]++;
                    count++;
                    low = min(low, abs(a[i][j]));
                }
            }
        }

        if((count%2)==0 || freq[0]>0){
            cout<<sum<<'\n';
        }else{
            cout<<(sum - 2*low)<<'\n';
        }

    }

    return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        vector<int> freq(102,0);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
            }
        }

        int low = 100;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                sum+=abs(a[i][j]);
                if(a[i][j]==0){
                    freq[0]++;
                }
                if(a[i][j]<0){
                    freq[abs(a[i][j])]++;
                    count++;
                }
                low = min(low, abs(a[i][j]));
            }
        }

        if((count%2)==0 || freq[0]>0){
            cout<<sum<<'\n';
        }else{
            cout<<(sum - 2*low)<<'\n';
        }

    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){

        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        vector<int> freq(110,0);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
                sum+=abs(a[i][j]);
                if(a[i][j]==0){
                    freq[0]++;
                }
                if(a[i][j]<0){
                    freq[abs(a[i][j])]++;
                    count++;
                }
            }
        }

        if((count%2)==0){
            cout<<sum<<'\n';
        }else{
            if(freq[0]>0){
                cout<<sum<<'\n';
            }else{
                for(int i=1; i<=100; i++){
                    if(freq[i]>0){
                        sum-=(2*i);
                        break;
                    }
                }
                cout<<sum<<'\n';
            }
        }

    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){

        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        vector<int> freq(110,0);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
                sum+=abs(a[i][j]);
                if(a[i][j]<=0){
                    freq[abs(a[i][j])]++;
                    count++;
                }
            }
        }

        if((count%2)==0){
            cout<<sum<<'\n';
        }else{
            if(freq[0]>0){
                cout<<sum<<'\n';
            }else{
                for(int i=1; i<=100; i++){
                    if(freq[i]>0){
                        sum-=(2*i);
                        break;
                    }
                }
                cout<<sum<<'\n';
            }
        }

    }

    return 0;
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;
    while(t--){

        int n, m;
        cin >> n >> m;
        int a[n][m];
        int sum=0;
        int freq[110];
        memset(freq,0,sizeof freq);
        int count=0;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                cin >> a[i][j];
                sum+=abs(a[i][j]);
                if(a[i][j]<=0){
                    freq[abs(a[i][j])]++;
                    count++;
                }
            }
        }

        if((count%2)==0){
            cout<<sum<<'\n';
        }else{
            if(freq[0]>0){
                cout<<sum<<'\n';
            }else{
                for(int i=1; i<=100; i++){
                    if(freq[i]>0){
                        cout<<i<<' '<<sum<<'\n';
                        sum-=(2*i);
                        break;
                    }
                }
                cout<<sum<<'\n';
            }
        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    cin >> a[i][j];
            }
            pi idx; int neg=0,mn=1e9;
            for(int i=0;i<n;i++){
                neg=0,mn=1e9;
                for(int j=0;j<m;j++){
                    if(abs(a[i][j])>mn){
                            mn=abs(a[i][j]),idx.ft=i,idx.sc=j;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    ans+=a[i][j];
            }
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0,neg=0,mn=1e10; pi idx;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                    cin >> a[i][j];
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                    if(a[i][j]<mn) mn=a[i][j],idx={i,j};
                    ans+=a[i][j];
                }
            }
            if(neg&1) ans-=2*a[idx.ft][idx.sc];
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    cin >> a[i][j];
            }
            pi idx; int neg=0,mn=1e9;
            for(int i=0;i<n;i++){
                neg=0,mn=1e9;
                for(int j=0;j<m;j++){
                    if(abs(a[i][j])>mn){
                            mn=abs(a[i][j]),idx.ft=i,idx.sc=j;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<m;i++){
                    neg=0,mn=1e9;
                for(int j=0;j<n;j++){
                    if(abs(a[j][i])>mn){
                            mn=abs(a[j][i]),idx.ft=j,idx.sc=i;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    ans+=a[i][j];
            }
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    cin >> a[i][j];
            }
            pi idx; int neg=0,mn=1e9;
            for(int i=0;i<n;i++){
                neg=0,mn=1e9;
                for(int j=0;j<m;j++){
                    if(abs(a[i][j])<mn){
                            mn=abs(a[i][j]),idx.ft=i,idx.sc=j;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<m;i++){
                    neg=0,mn=1e9;
                for(int j=0;j<n;j++){
                    if(abs(a[j][i])<mn){
                            mn=abs(a[j][i]),idx.ft=j,idx.sc=i;
                    }
                    if(a[j][i]<0) a[j][i]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    ans+=a[i][j];
            }
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0,ok=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    cin >> a[i][j];
            }
            pi idx; int neg=0,mn=1e9;
            for(int i=0;i<n;i++){
                neg=0;
                for(int j=0;j<m;j++){
                    if(abs(a[i][j])<mn){
                            mn=abs(a[i][j]),idx.ft=i,idx.sc=j;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) ok=1;
            }
            for(int i=0;i<m;i++){
                    neg=0;
                for(int j=0;j<n;j++){
                    if(abs(a[j][i])<mn){
                            mn=abs(a[j][i]),idx.ft=j,idx.sc=i;
                    }
                    if(a[j][i]<0) a[j][i]*=-1,neg++;
                }
                if( neg&1 ) ok=1;
            }

            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    ans+=a[i][j];
            }
            if(ok) ans-=2*a[idx.ft][idx.sc];
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sc second
#define pb push_back
#define pf push_front
#define vi vector<int>
#define pi pair<ll,ll>
#define p_q priority_queue
#define INF 100000000000000
const ll N=1e5+7;
ll n,m,a[505][505];
int main(){
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     int t;
     cin >> t;
     while(t--){
            cin >> n >> m; ll ans=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    cin >> a[i][j];
            }
            pi idx; int neg=0,mn=1e9;
            for(int i=0;i<n;i++){
                neg=0,mn=1e9;
                for(int j=0;j<m;j++){
                    if(abs(a[i][j])<mn){
                            mn=abs(a[i][j]),idx.ft=i,idx.sc=j;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<m;i++){
                    neg=0,mn=1e9;
                for(int j=0;j<n;j++){
                    if(abs(a[j][i])<mn){
                            mn=abs(a[j][i]),idx.ft=j,idx.sc=i;
                    }
                    if(a[i][j]<0) a[i][j]*=-1,neg++;
                }
                if( neg&1 ) a[idx.ft][idx.sc]*=-1;
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<m;j++)
                    ans+=a[i][j];
            }
            cout << ans <<'\n';
     }

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
const int MAX = 1e9;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t;
	cin >> t;
	while (t--) {
		int n, m;
		cin >> n >> m;
		int a[n][m];
		int f = 0;
		int ans = 0;
		int c = 0;
		int x = 101;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> a[i][j];
				ans += abs(a[i][j]);
				x = min(abs(a[i][j]), x);
				if (a[i][j] == 0) f = 1;
				if (a[i][j] < 0) c++;
			}
		}
		if (f) cout << ans << endl;
		else if ((c % 2)) cout << ans - 2 * x << endl;
		else cout << ans << endl;
	}

}


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

int main(){
	int t;
	cin>>t;

	while(t--){
      int n,m;
      cin>>n>>m;

        int a[n][m];
        int num =0;
        int min = 1000;
        int sum=0;

    	for(int i=0;i<n;i++){
         	for(int j=0;j<m;j++){
          	    cin>>a[i][j];

          		if(abs(a[i][j])<min){
          			min = abs(a[i][j]);
				}
			}
        }
		for(int i=0;i<n;i++){
		    for(int j=0;j<m;j++){

		        if(a[i][j]<0){
		           num++;
		        }
			}
        }

		for(int i=0;i<n;i++){
		    for(int j=0;j<m;j++){
				if(a[i][j]<0){
					sum = sum +(-1)*a[i][j];
				}
				else{
					sum = sum + a[i][j];
				}
			}
        }

       	if(num%2==0){
      		cout<<sum<<endl;
		}
		else{
			cout<<sum - 2*min<<endl;
		}

   }

}


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

int main(){
	int t;
	cin>>t;

	while(t--){
		int n,m;
		cin>>n>>m;

		int a[3][4];
		int sum =0;

		int count =0;

		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin>>a[i][j];

				if(a[i][j]<0){
					count++;
				}
			}
		}

		if(count%2==0){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(a[i][j]<0){
						sum = sum + ((-1)*a[i][j]);
					}
					else{
						sum = sum +a[i][j];
					}

				}
			}
		}
		else{
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					sum = sum + a[i][j];
				}
			}
		}

		if(sum <0){
			cout<<(-1)*sum<<endl;
		}
		else {
			cout<<sum<<endl;
		}

	}
}


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

int main(){
	int t;
	cin>>t;

	while(t--){
		int n,m;
		cin>>n>>m;

		int a[3][4];
		int sum =0;

		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				cin>>a[i][j];

				sum = sum +a[i][j];

			}
		}

		cout<<abs(sum)<<endl;
	}
}


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

	int main(){
		int t;
		cin>>t;

		while(t--){
			long long n,m;
			cin>>n>>m;

			int a[n][m];
			long long sum =0;

			long long count =0;
			long long pos =0;

			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					cin>>a[i][j];

					if(a[i][j]<0){
						count++;
					}
					else{
						pos++;
					}
				}
			}

			if(count>pos){
				for(int i=0;i<n;i++){
					for(int j=0;j<m;j++){
						if(a[i][j]<0){
							sum = sum + ((-1)*a[i][j]);
						}
						else{
							sum = sum +a[i][j];
						}

					}
				}
			}
			else{
				for(int i=0;i<n;i++){
					for(int j=0;j<m;j++){
						sum = sum + a[i][j];
					}
				}
			}

			if(sum <0){
				cout<<(-1)*sum<<endl;
			}
			else {
				cout<<sum<<endl;
			}
		}
	}