#include <bits/stdc++.h>
int gcd(int a, int b) {
  int r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main() {
  int n, m;
  int deg1, deg2;
  scanf("%d %d", &n, &m);
  for (int i = 0, a; i <= n; i++) {
    scanf("%d", &a);
    if (i == 0) deg1 = a;
  }
  for (int i = 0, a; i <= m; i++) {
    scanf("%d", &a);
    if (i == 0) deg2 = a;
  }
  if (n > m) {
    if (deg1 > 0 && deg2 > 0 || (deg1 < 0 && deg2 < 0))
      printf("Infinity");
    else
      printf("-Infinity");
  } else if (m > n)
    printf("0/1");
  else {
    while (gcd(deg1, deg2) != 1) {
      int r = gcd(deg1, deg2);
      deg1 /= r;
      deg2 /= r;
    }
    if (deg1 < 0 && deg2 < 0 || (deg1 > 0 && deg2 > 0))
      printf("%d/%d", deg1, deg2);
    else
      printf("-%d/%d", abs(deg1), abs(deg2));
  }
  return 0;
}
