#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  int t;
  cin >> t;
  while (t--) {
    scanf("%lld %lld", &n, &m);
    long long x = n, s = 0;
    if (n < m) {
      s = (m - x) / 5;
      x += s * 5;
      if (m - x == 1 || m - x == 2)
        s += 1;
      else if (m == x)
        s = s;
      else
        s += 2;
    } else {
      s = (x - m) / 5;
      x -= s * 5;
      if (x - m == 1 || x - m == 2)
        s += 1;
      else if (m != x)
        s += 2;
    }
    printf("%lld\n", s);
  }
  return 0;
}
