Integrated circuit with well and substrate contacts