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

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

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

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

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

f = A("f")
e = B("e")
m = C("m")
a = D("a")
c = E("c")
g = B("g")
h = A("h")
k = D("k")

f.o = e
f.z = g
e.s = a
m.w = h
m.x = c
a.w = g
c.t = g
c.o = f
g.s = a
h.o = e
h.z = g
k.w = g
assert c.t.s.w.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: B = None
        self.txt = txt

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

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

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

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

f = A("f")
e = B("e")
m = C("m")
a = D("a")
c = E("c")
g = B("g")
h = A("h")
k = D("k")

f.o = e
f.z = g
e.s = a
m.w = h
m.x = c
a.w = g
c.t = g
c.o = f
g.s = a
h.o = e
h.z = g
k.w = g
assert c.t.s.w.s.w.s.w.txt == "g"