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

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

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

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

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

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

g.y = h
h.z = b
m.y = h
m.u = b
m.t = b
m.w = d
n.w = g
n.q = m
d.p = h
b.y = h
assert m.u.y.z.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

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

g.y = h
h.z = b
m.y = h
m.u = b
m.t = b
m.w = d
n.w = g
n.q = m
d.p = h
b.y = h
assert m.u.y.z.y.z.y.txt == "h"