#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int64_t t;
  cin >> t;
  for (int64_t i = 0; i < t; i++) {
    int64_t a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << endl;
      continue;
    }
    int64_t k = abs(b - a);
    int64_t ans = k / 5;
    k %= 5;
    ans += k / 2;
    k %= 2;
    ans += k;
    cout << ans << endl;
  }
}
