#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
int main() {
  long long int t = 1;
  cin >> t;
  while (t--) {
    long long int a, b, f = 0;
    cin >> a >> b;
    if (a == b) {
      f = 0;
    } else if (a > b) {
      int c = (a - b) / 5;
      f += (a - b) / 5;
      a -= c * 5;
      c = (a - b) / 2;
      f += (a - b) / 2;
      a -= c * 2;
      f += a - b;
    } else {
      int c = (b - a) / 5;
      f += (b - a) / 5;
      a += c * 5;
      c = (b - a) / 2;
      f += (b - a) / 2;
      a += c * 2;
      f += b - a;
    }
    cout << f << endl;
  }
  return 0;
}
