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

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

j = A("j")
f = B("f")
a = B("a")
k = A("k")
b = A("b")
h = A("h")
l = A("l")
i = B("i")
g = B("g")
e = B("e")

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

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

j = A("j")
f = B("f")
a = B("a")
k = A("k")
b = A("b")
h = A("h")
l = A("l")
i = B("i")
g = B("g")
e = B("e")

j.u = k
j.z = b
f.x = i
f.p = j
a.x = e
a.p = j
k.u = h
k.z = l
b.u = h
b.z = h
h.u = l
h.z = l
l.u = k
l.z = b
i.x = e
i.p = b
g.x = e
g.p = l
e.x = g
e.p = k
assert i.p.z.z.txt == "l"