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

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

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

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

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

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

a.x = i
a.y = j
j.p = e
j.u = f
f.p = e
f.u = h
e.p = f
e.u = h
l.x = k
l.y = h
k.x = a
k.y = e
h.p = f
h.u = j
m.x = a
m.y = f
i.x = l
i.y = e
assert i.x.x.x.y.u.u.p.p.p.txt == "f"