#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) {
      int hold = b;
      b = a;
      a = hold;
    }
    int fives = (b - a) / 5;
    b -= fives * 5;
    int two = (b - a) / 2;
    b -= two * 2;
    int ones = b - a;
    cout << fives + two + ones << endl;
  }
  return 0;
}
