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

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

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

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

e.u = d
e.r = c
d.y = c
c.q = d
c.u = d
assert e.u.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: C = None
        self.txt = txt

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

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

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

e.u = d
e.r = c
d.y = c
c.q = d
c.u = d
assert e.u.y.u.txt == "d"