#!/usr/bin/env python
from sys import argv, stdin
from pylab import plot, subplot, show, savefig, axis

# Subplot counts
hor = 5
ver = 2

# Collect data
lines = stdin.readlines()
stride = int(len(lines) / (hor * ver))
y = []
x = map(float, lines[0].split(' '))
for line in lines[1::stride]:
    y += [map(float, line.split(' '))]

# Plot and optionally save data
for i in range(len(y)):
    subplot(ver, hor, i + 1)
    plot(x, y[i], '-')
    axis([0, 1, -1, 1])
if len(argv) > 1:
    savefig(argv[1])
show()
