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

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

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

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

k = A("k")
c = B("c")
f = C("f")
m = D("m")
d = B("d")
a = C("a")
b = A("b")
j = B("j")
l = D("l")
i = C("i")

k.u = b
c.s = a
c.t = l
f.x = b
m.p = l
m.z = j
m.u = c
m.x = i
d.s = f
d.t = m
a.x = k
b.u = k
j.s = a
j.t = l
l.p = m
l.z = j
l.u = j
l.x = i
i.x = k
assert b.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

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

k = A("k")
c = B("c")
f = C("f")
m = D("m")
d = B("d")
a = C("a")
b = A("b")
j = B("j")
l = D("l")
i = C("i")

k.u = b
c.s = a
c.t = l
f.x = b
m.p = l
m.z = j
m.u = c
m.x = i
d.s = f
d.t = m
a.x = k
b.u = k
j.s = a
j.t = l
l.p = m
l.z = j
l.u = j
l.x = i
i.x = k
assert b.u.u.u.u.u.txt == "k"