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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.u: C = None
        self.v: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

b.w = h
a.x = i
a.r = i
a.y = e
a.u = d
a.v = g
i.s = b
e.t = g
n.u = e
n.z = a
h.w = b
d.s = h
g.t = e
assert a.u.s.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.u: C = None
        self.v: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

b.w = h
a.x = i
a.r = i
a.y = e
a.u = d
a.v = g
i.s = b
e.t = g
n.u = e
n.z = a
h.w = b
d.s = h
g.t = e
assert a.u.s.w.w.w.w.w.w.txt == "h"