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

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

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

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

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

a = A("a")
h = B("h")
f = C("f")
d = D("d")
j = E("j")
k = C("k")

a.t = h
h.x = a
h.w = d
f.u = d
f.w = a
d.t = k
d.u = h
j.x = h
k.u = d
k.w = a
assert k.u.t.u.u.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

a = A("a")
h = B("h")
f = C("f")
d = D("d")
j = E("j")
k = C("k")

a.t = h
h.x = a
h.w = d
f.u = d
f.w = a
d.t = k
d.u = h
j.x = h
k.u = d
k.w = a
assert k.u.t.u.u.x.t.txt == "h"