func_code_string: #include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1, n, k, fact, a, b;     cin >> t;     while (t--) {       cin >> a >> b;       if (a == 1)         cout <<  0 n ;       else if (a == 2)         cout << b <<   n ;       else         cout << 2 * b <<   n ;     }     return 0;   }   