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

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

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

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

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

a.x = l
a.s = n
n.w = m
m.t = i
m.x = i
i.x = d
i.y = d
i.s = b
f.w = b
b.t = d
b.x = i
d.x = i
d.y = i
d.s = m
j.w = b
l.x = a
l.s = n
assert f.w.t.s.t.s.x.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.txt = txt

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

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

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

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

a.x = l
a.s = n
n.w = m
m.t = i
m.x = i
i.x = d
i.y = d
i.s = b
f.w = b
b.t = d
b.x = i
d.x = i
d.y = i
d.s = m
j.w = b
l.x = a
l.s = n
assert f.w.t.s.t.s.x.s.x.txt == "i"