#include <bits/stdc++.h>
int main() {
  int s[3] = {1, 2, 5};
  int a, b, count = 0;
  int t, x;
  int i, m;
  scanf("%d", &t);
  while (t--) {
    count = 0;
    scanf("%d %d", &a, &b);
    x = abs(a - b);
    for (i = 2; i >= 0; i--) {
      m = x / s[i];
      count += m;
      x = x % s[i];
      if (x == 0) break;
    }
    printf("%d\n", count);
  }
  return 0;
}
