#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, x, y, i, sol, a, b, t;
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  cin >> t;
  for (; t; t--) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    sol = 0;
    while (b > a) {
      if (b - a >= 5) {
        x = (b - a) / 5;
        b -= 5 * x;
        sol += x;
      } else if (b - a >= 2) {
        x = (b - a) / 2;
        b -= 2 * x;
        sol += x;
      } else if (b - a >= 1)
        b--, sol++;
    }
    cout << sol << '\n';
  }
  return 0;
}
