#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  const array<int, 3> values = {1, 2, 5};
  int testsCount;
  cin >> testsCount;
  while (testsCount--) {
    int a, b;
    cin >> a >> b;
    int diff = abs(a - b);
    int answer = 0;
    for (int i = 2; i >= 0; i--) {
      answer += (diff / values[i]);
      diff %= values[i];
    }
    cout << answer << '\n';
  }
  return EXIT_SUCCESS;
}
