[LintCode] Nuts & Bolts Problem