#include <bits/stdc++.h>
using namespace std;
long long n, i, s, q, w, s1, q1, w1;
int main() {
  cin >> n;
  long long a[n], b[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for (i = 0; i < n; i++) {
    if (abs(a[i] - b[i]) <= 4) {
      s = abs(a[i] - b[i]) % 2;
      s1 = abs(a[i] - b[i]) / 2;
      q = s % 1;
      q1 = s / 1;
      cout << s1 + q1 << endl;
    } else if (abs(a[i] - b[i]) == 0)
      cout << 0 << endl;
    else {
      s = abs(a[i] - b[i]) % 5;
      s1 = abs(a[i] - b[i]) / 5;
      q = s % 2;
      q1 = s / 2;
      w = q % 1;
      w1 = q / 1;
      cout << s1 + q1 + w1 << endl;
    }
  }
}
