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

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

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

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

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

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

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