#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  int t = read();
  while (t--) {
    int a = read(), b = read(), ans = 0;
    if (a == b)
      printf("%d\n", 0);
    else {
      if (a > b) swap(a, b);
      ans += (b - a) / 5;
      a += 5 * ans;
      if ((b - a) % 2 == 0)
        ans += (b - a) / 2;
      else
        ans += (b - a) / 2 + 1;
      cout << ans << endl;
    }
  }
  return 0;
}
