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

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

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

m = A("m")
n = B("n")
h = C("h")
j = A("j")

m.y = h
n.r = h
n.y = h
n.t = h
h.q = m
h.u = n
j.y = h
assert h.u.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

m = A("m")
n = B("n")
h = C("h")
j = A("j")

m.y = h
n.r = h
n.y = h
n.t = h
h.q = m
h.u = n
j.y = h
assert h.u.r.q.txt == "m"