#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {1, 0, 0, -1};
const int dy[4] = {0, -1, 1, 0};
void solve() {
  int A, P;
  cin >> A >> P;
  cout << (3 * A + P) / 2 << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  cin >> q;
  while (q--) solve();
}
