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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: B = None
        self.txt = txt

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

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

d.q = j
d.s = k
d.o = m
g.z = b
g.t = b
m.s = b
m.o = i
k.s = b
k.o = h
i.s = g
i.o = h
h.s = b
h.o = k
f.q = j
f.s = c
f.o = h
c.s = g
c.o = h
j.q = f
j.s = c
j.o = h
b.z = g
b.t = g
assert b.t.z.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: C = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: B = None
        self.txt = txt

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

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

d.q = j
d.s = k
d.o = m
g.z = b
g.t = b
m.s = b
m.o = i
k.s = b
k.o = h
i.s = g
i.o = h
h.s = b
h.o = k
f.q = j
f.s = c
f.o = h
c.s = g
c.o = h
j.q = f
j.s = c
j.o = h
b.z = g
b.t = g
assert b.t.z.t.t.z.txt == "g"