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

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

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

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

j = A("j")
g = B("g")
l = C("l")
d = D("d")
b = A("b")
m = D("m")
n = C("n")

j.u = m
j.s = b
g.z = b
g.s = n
l.y = d
l.o = b
d.t = g
d.u = g
d.s = l
b.u = d
b.s = j
m.t = g
m.u = g
m.s = n
n.y = d
n.o = j
assert g.s.o.s.u.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.s: A = None
        self.txt = txt

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

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

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

j = A("j")
g = B("g")
l = C("l")
d = D("d")
b = A("b")
m = D("m")
n = C("n")

j.u = m
j.s = b
g.z = b
g.s = n
l.y = d
l.o = b
d.t = g
d.u = g
d.s = l
b.u = d
b.s = j
m.t = g
m.u = g
m.s = n
n.y = d
n.o = j
assert g.s.o.s.u.s.txt == "l"