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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: D = None
        self.q: D = None
        self.p: D = None
        self.u: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: E = None
        self.txt = txt

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

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

m.o = h
b.v = c
b.y = c
b.q = f
b.p = f
b.u = f
a.w = f
f.p = a
f.r = k
e.q = a
n.o = h
c.p = a
c.r = e
h.v = f
h.y = f
h.q = f
h.p = c
h.u = c
k.q = a
d.o = h
assert h.u.p.w.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: D = None
        self.q: D = None
        self.p: D = None
        self.u: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: E = None
        self.txt = txt

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

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

m.o = h
b.v = c
b.y = c
b.q = f
b.p = f
b.u = f
a.w = f
f.p = a
f.r = k
e.q = a
n.o = h
c.p = a
c.r = e
h.v = f
h.y = f
h.q = f
h.p = c
h.u = c
k.q = a
d.o = h
assert h.u.p.w.p.w.txt == "f"