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

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

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

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

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

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

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

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

i.r = f
c.o = j
c.w = j
c.t = h
m.z = g
j.r = f
d.z = g
f.z = d
g.z = m
b.o = i
b.w = j
b.t = h
h.r = m
assert b.w.r.z.z.z.z.txt == "g"