Preliminaries for first two problems.