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

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

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

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

m.s = d
m.x = e
d.q = m
j.u = e
e.u = j
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: C = None
        self.txt = txt

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

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

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

m.s = d
m.x = e
d.q = m
j.u = e
e.u = j
assert j.u.u.u.txt == "e"