#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N], b[N];
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i <= m; i++) scanf("%d", &b[i]);
  if (n > m) {
    if (a[0] * b[0] > 0)
      puts("Infinity");
    else
      puts("-Infinity");
  } else if (n < m) {
    printf("0/1\n");
  } else {
    if (a[0] > 0 && b[0] > 0 || a[0] < 0 && b[0] < 0) {
      a[0] = abs(a[0]);
      b[0] = abs(b[0]);
      int t = gcd(a[0], b[0]);
      a[0] /= t;
      b[0] /= t;
      printf("%d/%d\n", a[0], b[0]);
    } else {
      a[0] = abs(a[0]);
      b[0] = abs(b[0]);
      int t = gcd(a[0], b[0]);
      a[0] /= t;
      b[0] /= t;
      printf("-%d/%d\n", a[0], b[0]);
    }
  }
  return 0;
}
