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

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

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

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

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

b = A("b")
g = B("g")
c = C("c")
k = D("k")
d = E("d")
h = C("h")
e = A("e")

b.t = c
g.t = k
g.r = e
c.u = g
c.z = g
c.s = g
c.q = e
k.u = h
d.w = e
d.v = g
d.x = h
d.u = b
h.u = g
h.z = g
h.s = g
h.q = e
e.t = c
assert d.w.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

b = A("b")
g = B("g")
c = C("c")
k = D("k")
d = E("d")
h = C("h")
e = A("e")

b.t = c
g.t = k
g.r = e
c.u = g
c.z = g
c.s = g
c.q = e
k.u = h
d.w = e
d.v = g
d.x = h
d.u = b
h.u = g
h.z = g
h.s = g
h.q = e
e.t = c
assert d.w.t.u.t.txt == "k"