#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
long long prime[1000001];
using namespace std;
int Prime(int a) {
  for (int i = 2; i <= a / 2; ++i) {
    if (a % i == 0) {
      return 0;
    }
  }
  return 1;
}
void sieve() {
  for (int i = 2; i <= 1000000; i++) prime[i] = 1;
  int maxn = 1000000;
  for (int i = 2; i * i <= maxn; i++) {
    if (prime[i] == 1) {
      for (int j = i; j * j <= maxn; j += i) {
        prime[j] = 0;
      }
    }
  }
}
void fibo(long long a[], long long n) {
  long long x = 0;
  long long y = 1;
  a[0] = 0;
  a[1] = 1;
  for (long long i = 2; i < n; ++i) {
    a[i] = (x + y) % 10;
    x = y;
    y = a[i];
  }
}
bool binarySearch(vector<long long> arr, int l, int r, int x) {
  if (r >= l) {
    int mid = l + (r - l) / 2;
    if (arr[mid] == x) return 1;
    if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
    return binarySearch(arr, mid + 1, r, x);
  }
  return 0;
}
long long s[200001], x, a[200001];
void bs(long long low, long long high) {
  long long mid = (low + high) / 2;
  if (s[mid] == x) {
    cout << mid + 1 << " " << a[mid];
  } else if ((x < s[mid]) && (x >= s[mid - 1])) {
    cout << mid << " " << x - s[mid - 1];
  } else if (x > s[mid]) {
    return bs(mid + 1, high);
  } else {
    return bs(low, mid - 1);
  }
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long t, n, k, x, r, m, s, y, a, b, c;
  string z;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    if (a > b) {
      a = a ^ b;
      b = a ^ b;
      a = a ^ b;
    }
    k = 0;
    x = b - a;
    k += x / 5;
    x %= 5;
    k += x / 2;
    x %= 2;
    k += x;
    cout << k << endl;
  }
  return 0;
}
