#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << 0 << '\n';
      continue;
    }
    if (a - b > 5) {
      int answ = 0;
      int cant = (a - b) / 5;
      answ = answ + cant;
      a = a - cant * 5;
      if (a - b == 1 or a - b == 2)
        answ = answ + 1;
      else {
        if (a != b) answ = answ + 2;
      }
      cout << answ << '\n';
      continue;
    }
    if (b - a > 5) {
      int answ = 0;
      int cant = (b - a) / 5;
      a = a + cant * 5;
      answ = answ + cant;
      if (b - a == 1 or b - a == 2)
        answ = answ + 1;
      else {
        if (a != b) answ = answ + 2;
      }
      cout << answ << '\n';
      continue;
    }
    if (abs(a - b) == 1 or abs(a - b) == 2 or abs(a - b) == 5)
      cout << 1 << '\n';
    else
      cout << 2 << '\n';
  }
  return 0;
}
