#include <bits/stdc++.h>
using namespace std;
int minimum(int x, int y) { return min(x, y); }
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    int a, b;
    cin >> a >> b;
    if (a == b)
      cout << 0 << endl;
    else if (a > b) {
      int k = (a - b) / 5;
      int x = a - 5 * k;
      if (x == b) {
        cout << k << endl;
        continue;
      }
      int ans = 999999999;
      if (x - b == 1 || x - b == 2)
        ans = k + 1;
      else
        ans = k + 2;
      x = a - 5 * (k + 1);
      if (x >= 0) {
        if (b - x == 1 || b - x == 2)
          ans = minimum(ans, k + 1 + 1);
        else
          ans = minimum(k + 2 + 1, ans);
      }
      cout << ans << endl;
    } else {
      int k = (b - a) / 5;
      int x = a + 5 * k;
      if (x == b) {
        cout << k << endl;
        continue;
      }
      int ans = 999999999;
      if (b - x == 1 || b - x == 2)
        ans = k + 1;
      else
        ans = k + 2;
      x = a + 5 * (k + 1);
      if (x - b == 1 || x - b == 2)
        ans = minimum(ans, k + 1 + 1);
      else
        ans = minimum(k + 2 + 1, ans);
      cout << ans << endl;
    }
  }
}
