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

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

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

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

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

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

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

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

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

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

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

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

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