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

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.o: D = None
        self.q: D = None
        self.z: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: D = None
        self.y: B = None
        self.txt = txt

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

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

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

b.o = e
f.t = l
f.p = l
f.o = d
f.q = d
f.z = n
l.v = d
l.r = e
l.y = f
e.q = d
e.x = d
e.w = f
n.z = f
n.y = b
d.q = e
d.x = e
d.w = f
h.z = f
h.y = b
a.o = d
assert h.z.q.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.o: D = None
        self.q: D = None
        self.z: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.r: D = None
        self.y: B = None
        self.txt = txt

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

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

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

b.o = e
f.t = l
f.p = l
f.o = d
f.q = d
f.z = n
l.v = d
l.r = e
l.y = f
e.q = d
e.x = d
e.w = f
n.z = f
n.y = b
d.q = e
d.x = e
d.w = f
h.z = f
h.y = b
a.o = d
assert h.z.q.x.w.txt == "f"