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

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

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

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

l = A("l")
b = B("b")
k = C("k")
c = D("c")
j = B("j")
f = D("f")

l.u = c
b.z = k
b.y = k
b.x = k
k.x = l
k.p = c
c.u = j
c.z = f
c.w = l
c.r = l
j.z = k
j.y = k
j.x = k
f.u = b
f.z = c
f.w = l
f.r = l
assert k.p.w.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

l = A("l")
b = B("b")
k = C("k")
c = D("c")
j = B("j")
f = D("f")

l.u = c
b.z = k
b.y = k
b.x = k
k.x = l
k.p = c
c.u = j
c.z = f
c.w = l
c.r = l
j.z = k
j.y = k
j.x = k
f.u = b
f.z = c
f.w = l
f.r = l
assert k.p.w.u.u.txt == "j"