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

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

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

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

l = A("l")
g = B("g")
j = C("j")
a = D("a")
i = D("i")
m = B("m")
k = C("k")

l.z = g
l.x = k
l.w = i
g.u = l
j.t = l
j.r = l
a.r = g
a.y = g
a.x = i
a.s = j
i.r = m
i.x = a
i.y = g
i.s = j
m.u = l
k.t = l
k.r = l
assert g.u.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.x: C = None
        self.w: D = None
        self.txt = txt

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

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

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

l = A("l")
g = B("g")
j = C("j")
a = D("a")
i = D("i")
m = B("m")
k = C("k")

l.z = g
l.x = k
l.w = i
g.u = l
j.t = l
j.r = l
a.r = g
a.y = g
a.x = i
a.s = j
i.r = m
i.x = a
i.y = g
i.s = j
m.u = l
k.t = l
k.r = l
assert g.u.x.r.txt == "l"