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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: C = None
        self.o: B = None
        self.u: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.y: E = None
        self.o: C = None
        self.q: D = None
        self.txt = txt

h = A("h")
c = B("c")
m = C("m")
e = D("e")
a = E("a")
d = F("d")

h.o = a
c.p = h
m.s = c
m.o = a
m.z = a
e.r = a
e.u = a
e.w = m
e.o = c
a.w = e
a.q = m
a.z = m
a.x = m
d.s = h
d.z = c
d.y = a
d.o = m
d.q = e
assert a.w.w.s.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: C = None
        self.o: B = None
        self.u: E = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: B = None
        self.y: E = None
        self.o: C = None
        self.q: D = None
        self.txt = txt

h = A("h")
c = B("c")
m = C("m")
e = D("e")
a = E("a")
d = F("d")

h.o = a
c.p = h
m.s = c
m.o = a
m.z = a
e.r = a
e.u = a
e.w = m
e.o = c
a.w = e
a.q = m
a.z = m
a.x = m
d.s = h
d.z = c
d.y = a
d.o = m
d.q = e
assert a.w.w.s.p.o.txt == "a"