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

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

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

m = A("m")
j = B("j")
b = C("b")
e = A("e")
h = C("h")

m.q = e
m.t = b
j.t = e
j.s = e
b.u = j
e.q = m
e.t = h
h.u = j
assert h.u.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.t: C = None
        self.txt = txt

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

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

m = A("m")
j = B("j")
b = C("b")
e = A("e")
h = C("h")

m.q = e
m.t = b
j.t = e
j.s = e
b.u = j
e.q = m
e.t = h
h.u = j
assert h.u.s.q.txt == "m"