The Polish and Russian languages use declensions; where endings of nouns and adjectives change, depending where and how they are used in a sentence. This includes proper nouns (e.g., names). For example, the name "Josek Wolf" might appear as "Joskiem Wolfem" on a civil marriage document in Russian Poland. You do not need to memorize Polish rules of grammar, however, for it is generally sufficient just to drop or slightly transform the endings to make sense of a name. Just be aware that declensions exist in Slavic and Baltic languages, so that names in documents will not always appear in documents as you would expect them to.