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

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

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

c = A("c")
e = B("e")
h = C("h")
m = B("m")

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

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

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

c = A("c")
e = B("e")
h = C("h")
m = B("m")

c.q = h
e.u = m
e.r = m
e.s = h
h.r = e
h.s = c
m.u = e
m.r = e
m.s = h
assert e.u.u.r.s.txt == "h"