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

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

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

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

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

b = A("b")
n = B("n")
h = C("h")
c = D("c")
m = E("m")

b.u = h
b.v = n
n.x = m
n.y = m
h.w = c
h.q = b
c.w = b
c.t = b
c.u = n
m.z = n
assert b.v.x.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: B = None
        self.txt = txt

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

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

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

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

b = A("b")
n = B("n")
h = C("h")
c = D("c")
m = E("m")

b.u = h
b.v = n
n.x = m
n.y = m
h.w = c
h.q = b
c.w = b
c.t = b
c.u = n
m.z = n
assert b.v.x.z.x.txt == "m"