Ferrari's Oliver Bearman narrowly misses out on Q3 after being edged out by Lewis Hamilton on his F1 debut.