Tight Bounds for Graph Homomorphism and Subgraph Isomorphism