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

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

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

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

f = A("f")
j = B("j")
e = C("e")
h = D("h")
k = B("k")
l = A("l")
i = C("i")
m = B("m")
d = A("d")

f.u = k
f.x = l
j.r = e
j.u = h
e.y = f
h.y = k
h.w = d
h.p = f
k.r = i
k.u = h
l.u = m
l.x = f
i.y = d
m.r = i
m.u = h
d.u = j
d.x = l
assert d.u.u.w.u.r.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: A = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
e = C("e")
h = D("h")
k = B("k")
l = A("l")
i = C("i")
m = B("m")
d = A("d")

f.u = k
f.x = l
j.r = e
j.u = h
e.y = f
h.y = k
h.w = d
h.p = f
k.r = i
k.u = h
l.u = m
l.x = f
i.y = d
m.r = i
m.u = h
d.u = j
d.x = l
assert d.u.u.w.u.r.y.u.txt == "k"