#include <fstream>
#include <iostream>
using namespace std;
//ostream &operator<< (ostream& out,const aboba &a) {
// out << a.name << " " << a.surname;
// return out;
//}
/*struct TACHKA {
char cvet;
int mosh;
string marka;
string model;
int pos;
float obiom;
int probeg;
};*/
int f(int a)
{
return a * 2 - 4*a;
}
int y(int b)
{
return -8 * b + 4;
}
int g(int a, int b)
{
return f(a) * a - y(b) * b;
}
int main()
{
ifstream file("baba.txt");
ofstream res("res.txt");
int a, b,k;
file >> k;
while (k != 0) {
file >> a >> b;
k--;
res << g(a,b) << endl;
}
}