# 【BZOJ 2301】【HAOI 2011】Problem b

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 50000;
int getint() {
int k = 0, fh = 1; char c = getchar();
for(; c < '0' || c > '9'; c = getchar())
if (c == '-') fh = -1;
for(; c >= '0' && c <= '9'; c = getchar())
k = k * 10 + c - '0';
return k * fh;
}
bool check[N + 3];
int prime[N + 3], mu[N + 3], sum[N + 3];
void shai() {
memset(check, 0, sizeof(check));
sum[1] = 1; mu[1] = 1; int num = 0;
for(int i = 2; i <= N; ++i) {
if (!check[i]) {
prime[++num] = i;
mu[i] = -1;
}
for(int j = 1; j <= num; ++j) {
if (i * prime[j] > N) break;
check[i * prime[j]] = 1;
if (i % prime[j] == 0) {mu[i * prime[j]] = 0; break;}
else mu[i * prime[j]] = - mu[i];
}
sum[i] = sum[i - 1] + mu[i];
}
}
long long Q(int n, int m) {
if (n > m) swap(n, m);
long long ret = 0;
for(int i = 1, la = 0; i <= n; i = la + 1) {
la = min(n / (n / i), m / (m / i));
ret += (long long) (sum[la] - sum[i - 1]) * (n / i) * (m / i);
}
return ret;
}
int main() {
shai();
int a, b, c, d, k, T;
long long QQ;