As I'm doing my Russian flashcards from back when I started my studies..... I'm finding that I struggle with и vs ы in written Russian.

Is there any logic to which consonant they appear after, or must I simply memorize each combination?