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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = None
        self.w: C = None
        self.u: E = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
d = B("d")
b = C("b")
j = D("j")
h = E("h")
i = D("i")
m = E("m")

c.o = d
c.q = d
c.t = h
d.r = h
d.x = b
d.q = b
b.v = c
j.z = b
j.t = b
j.w = b
j.u = h
j.r = c
h.w = d
i.z = b
i.t = b
i.w = b
i.u = h
i.r = c
m.w = d
assert b.v.q.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: B = None
        self.t: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.t: C = None
        self.w: C = None
        self.u: E = None
        self.r: A = None
        self.txt = txt

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

c = A("c")
d = B("d")
b = C("b")
j = D("j")
h = E("h")
i = D("i")
m = E("m")

c.o = d
c.q = d
c.t = h
d.r = h
d.x = b
d.q = b
b.v = c
j.z = b
j.t = b
j.w = b
j.u = h
j.r = c
h.w = d
i.z = b
i.t = b
i.w = b
i.u = h
i.r = c
m.w = d
assert b.v.q.r.w.r.txt == "h"