#include <bits/stdc++.h>
using namespace std;
bool ick_ili(int n, int m) {
  int x, y;
  n < 0 ? x = 0 : x = 1;
  m < 0 ? y = 0 : y = 1;
  return (!(x && y) && (x || y));
}
bool ick_ili(char n, char m) {
  n == '-' ? n = 0 : n = 1;
  m == '-' ? m = 0 : m = 1;
  return (!(n && m) && (n || m));
}
int main() {
  int n, m;
  cin >> n >> m;
  string s1, s2;
  cin.ignore();
  getline(cin, s1);
  getline(cin, s2);
  int kol1 = 0, kol2 = 0;
  string Z1, Z2;
  bool b1 = false;
  for (int i = 0; i < s1.length(); i++) {
    if (isspace(s1[i])) {
      if (b1 == true) {
        kol1++;
      }
      if (Z1 != "0" && b1 == false) {
        kol1++;
        b1 = true;
      }
    }
    if (b1 == false) {
      Z1 += s1[i];
    }
  }
  b1 = false;
  for (int i = 0; i < s2.length(); i++) {
    if (isspace(s2[i])) {
      if (b1 == true) {
        kol2++;
      }
      if (Z1 != "0" && b1 == false) {
        kol2++;
        b1 = true;
      }
    }
    if (b1 == false) {
      Z2 += s2[i];
    }
  }
  if (kol1 < kol2) {
    cout << "0/1" << endl;
  } else if (kol1 > kol2) {
    if (ick_ili(s2[0], s1[0])) {
      cout << "-Infinity" << endl;
    } else {
      cout << "Infinity" << endl;
    }
  } else {
    int T1, T2;
    istringstream ss1(Z1);
    ss1 >> T1;
    istringstream ss2(Z2);
    ss2 >> T2;
    for (int i = abs(max(T1, T2)); i >= 2; i--) {
      if (T1 % i == 0 && T2 % i == 0) {
        T1 /= i;
        T2 /= i;
      }
    }
    if (T1 < 0 || T2 < 0) {
      if (ick_ili(T1, T2)) {
        cout << '-' << abs(T1) << '/' << abs(T2) << endl;
      } else {
        cout << abs(T1) << '/' << abs(T2) << endl;
      }
    } else {
      cout << T1 << '/' << T2 << endl;
    }
  }
  return 0;
}
