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

class B:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
e = C("e")
h = D("h")
n = E("n")
i = D("i")
d = E("d")
k = D("k")
m = C("m")

b.t = i
j.v = d
e.r = b
e.p = b
e.q = d
h.o = m
n.z = h
n.o = d
n.y = d
n.w = b
i.o = m
d.z = i
d.o = n
d.y = n
d.w = b
k.o = e
m.r = b
m.p = b
m.q = n
assert m.p.t.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: E = None
        self.txt = txt

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

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

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

b = A("b")
j = B("j")
e = C("e")
h = D("h")
n = E("n")
i = D("i")
d = E("d")
k = D("k")
m = C("m")

b.t = i
j.v = d
e.r = b
e.p = b
e.q = d
h.o = m
n.z = h
n.o = d
n.y = d
n.w = b
i.o = m
d.z = i
d.o = n
d.y = n
d.w = b
k.o = e
m.r = b
m.p = b
m.q = n
assert m.p.t.o.r.txt == "b"