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

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

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

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

j = A("j")
f = B("f")
h = C("h")
d = D("d")
a = C("a")
m = A("m")
g = A("g")
i = B("i")

j.u = m
j.s = d
f.x = a
f.p = j
h.s = m
d.x = j
d.o = h
d.u = m
a.s = j
m.u = g
m.s = d
g.u = j
g.s = d
i.x = h
i.p = m
assert a.s.u.u.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: D = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
h = C("h")
d = D("d")
a = C("a")
m = A("m")
g = A("g")
i = B("i")

j.u = m
j.s = d
f.x = a
f.p = j
h.s = m
d.x = j
d.o = h
d.u = m
a.s = j
m.u = g
m.s = d
g.u = j
g.s = d
i.x = h
i.p = m
assert a.s.u.u.s.x.txt == "j"