#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  return (n2 == 0) ? n1 : gcd(n2, n1 % n2);
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  while (n--) {
    int a, b;
    cin >> a >> b;
    int val = abs(a - b), ans = 0;
    ans += val / 5;
    val -= val / 5 * 5;
    ans += val / 2;
    val -= val / 2 * 2;
    ans += val;
    cout << ans << endl;
  }
}
