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