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

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

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

b = A("b")
i = B("i")
j = C("j")
h = C("h")
c = A("c")
m = A("m")
d = A("d")

b.y = j
i.u = b
j.q = i
j.y = h
h.q = i
h.y = j
c.y = j
m.y = h
d.y = j
assert h.y.q.u.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
j = C("j")
h = C("h")
c = A("c")
m = A("m")
d = A("d")

b.y = j
i.u = b
j.q = i
j.y = h
h.q = i
h.y = j
c.y = j
m.y = h
d.y = j
assert h.y.q.u.y.y.y.txt == "j"