Fairfax to buy BlackBerry for $4.7 billion