#include <bits/stdc++.h>
#pragma GCC optimize("O3")
long long int gcd(long long int a, long long int b) {
  return (b ? gcd(b, a % b) : a);
}
long long int P(long long int B, long long int power) {
  long long int ans = 1;
  while (power > 0) {
    if (power % 2 == 1) {
      ans = (ans * B) % 1000000007;
    }
    B = (B * B) % 1000000007;
    power /= 2;
  }
  return ans;
}
bool isPrime(long long int n) {
  if (n <= 1) {
    return false;
  }
  if (n <= 3) {
    return true;
  }
  if (n % 2 == 0 || n % 3 == 0) {
    return false;
  }
  for (long long int i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << "\n";
    } else if (a < b) {
      int ans = 0;
      int temp = b - a;
      ans += (temp / 5);
      temp %= 5;
      ans += (temp / 2);
      temp %= 2;
      ans += temp;
      cout << ans << "\n";
    } else {
      int ans = 0;
      int temp = a - b;
      ans += (temp / 5);
      temp %= 5;
      ans += (temp / 2);
      temp %= 2;
      ans += temp;
      cout << ans << "\n";
    }
  }
  return 0;
}
