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

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

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

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

j = A("j")
m = B("m")
b = C("b")
f = D("f")
k = A("k")
l = C("l")
e = A("e")
g = D("g")
c = B("c")
i = D("i")

j.s = i
j.u = g
m.x = b
b.z = g
b.o = l
f.x = g
f.p = j
k.s = g
k.u = i
l.z = g
l.o = b
e.s = g
e.u = i
g.x = i
g.p = k
c.x = b
i.x = g
i.p = e
assert f.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: D = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
b = C("b")
f = D("f")
k = A("k")
l = C("l")
e = A("e")
g = D("g")
c = B("c")
i = D("i")

j.s = i
j.u = g
m.x = b
b.z = g
b.o = l
f.x = g
f.p = j
k.s = g
k.u = i
l.z = g
l.o = b
e.s = g
e.u = i
g.x = i
g.p = k
c.x = b
i.x = g
i.p = e
assert f.p.s.p.txt == "e"