class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: A = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

e = A("e")
d = B("d")
j = C("j")

e.r = j
e.x = j
d.y = j
d.t = j
d.r = e
j.y = d
assert d.r.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: A = None
        self.t: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

e = A("e")
d = B("d")
j = C("j")

e.r = j
e.x = j
d.y = j
d.t = j
d.r = e
j.y = d
assert d.r.x.y.txt == "d"