#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) {
  if (a > b) return b;
  return a;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long a, b;
    cin >> a >> b;
    long dif = abs(a - b);
    long ans = 0;
    ans += dif / 5;
    dif %= 5;
    ans += dif / 2;
    dif %= 2;
    ans += dif;
    cout << ans << endl;
  }
}
