read input to matrix