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

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

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

n = A("n")
f = B("f")
g = C("g")
b = A("b")
i = B("i")
h = C("h")
e = B("e")

n.y = h
n.o = h
f.u = h
g.q = b
g.w = e
b.y = h
b.o = g
i.u = g
h.q = b
h.w = i
e.u = h
assert f.u.w.u.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: C = None
        self.txt = txt

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

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

n = A("n")
f = B("f")
g = C("g")
b = A("b")
i = B("i")
h = C("h")
e = B("e")

n.y = h
n.o = h
f.u = h
g.q = b
g.w = e
b.y = h
b.o = g
i.u = g
h.q = b
h.w = i
e.u = h
assert f.u.w.u.q.y.txt == "h"