#include <bits/stdc++.h>
using namespace std;
int Foo(int a, int b) {
  int c = a % b;
  if (c == 0) {
    return b;
  }
  return Foo(b, c);
}
int a[110];
int b[110];
int main() {
  int n, m;
  int rec1, rec2;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) scanf("%d", &a[i]);
  for (int j = 0; j <= m; j++) scanf("%d", &b[j]);
  int k = 0;
  while (1) {
    rec1 = k;
    if (a[k] == 0) {
      n--;
      k++;
    } else
      break;
  }
  k = 0;
  while (1) {
    rec2 = k;
    if (b[k] == 0) {
      m--;
      k++;
    } else
      break;
  }
  if (n > m)
    if (a[rec1] * b[rec2] > 0)
      printf("Infinity");
    else
      printf("-Infinity");
  else if (n < m)
    printf("0/1");
  else {
    int maxcom;
    int flag;
    if (a[rec1] * b[rec2] > 0)
      flag = 1;
    else
      flag = 0;
    if (a[rec1] < 0) a[rec1] = -a[rec1];
    if (b[rec2] < 0) b[rec2] = -b[rec2];
    maxcom = Foo(a[rec1], b[rec2]);
    if (flag == 1)
      printf("%d/%d", a[rec1] / maxcom, b[rec2] / maxcom);
    else
      printf("-%d/%d", a[rec1] / maxcom, b[rec2] / maxcom);
  }
  return 0;
}
