#include <bits/stdc++.h>
using namespace std;
int gcd(int v, int vv) { return vv == 0 ? v : gcd(vv, v % vv); }
int main() {
  int powV1, powV2, v[101], v2[101], vv, vv2, x;
  cin >> powV1 >> powV2;
  for (int i = 0; i <= powV1; i++) {
    cin >> v[i];
  }
  for (int i = 0; i <= powV2; i++) {
    cin >> v2[i];
  }
  for (int i = 0; i < powV1; i++) {
    if (v[i] != 0) {
      vv = v[i];
      break;
    }
  }
  for (int i = 0; i < powV2; i++) {
    if (v2[i] != 0) {
      vv2 = v2[i];
      break;
    }
  }
  if (powV1 == 0) vv = v[0];
  if (powV2 == 0) vv2 = v2[0];
  if (powV1 > powV2) {
    if (vv * vv2 < 0)
      cout << "-Infinity" << endl;
    else
      cout << "Infinity" << endl;
  } else if (powV1 < powV2) {
    cout << "0/1" << endl;
  } else {
    x = gcd(abs(vv), abs(vv2));
    if (vv2 < 0) {
      vv2 *= -1;
      vv *= -1;
    }
    cout << vv / x << "/" << vv2 / x << endl;
  }
  return 0;
}
