#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    long long int result = abs(a - b);
    if (result == 0)
      cout << "0\n";
    else {
      long long int count = 0;
      if (result >= 5) {
        count = count + result / 5;
        result = result - 5 * (result / 5);
      }
      if (result == 0)
        cout << count << "\n";
      else {
        if (result >= 2) {
          count = count + result / 2;
          result = result - 2 * (result / 2);
        }
        if (result == 0)
          cout << count << "\n";
        else {
          if (result >= 1) {
            count = count + result;
            result = result - (result);
          }
          cout << count << "\n";
        }
      }
    }
  }
}
