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

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

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

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

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

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

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

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

b.z = e
b.o = a
b.y = n
e.w = b
h.z = d
h.u = g
d.z = g
d.u = g
n.w = b
i.z = n
i.y = n
i.o = h
a.z = h
a.u = g
g.z = d
g.u = h
assert d.z.u.z.z.u.z.u.txt == "g"