I am currently learning Salesforce. And I`ve got the task on courses about apex managed sharing rules. I need to use 3 standard objects - Account, Contact, User and 3 custom - Terr(as a territory), TeterritoryrrUser, Reference - junction objects in many-to-many relations. So I need to create a hierarchy of fields - country, region, city in Terr object in such a way, that User has access to specific territory and accounts, contacts on it. For example, if he has access to some region, he has access to all accounts in this region, including cities of this region. So I have tried to write some triggers for Account and User sharing rules, but I have got confused. I would be glad if someone gave me a hint, how to implement such a system.