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

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

b = A("b")
l = B("l")
m = A("m")
n = B("n")
f = B("f")
k = A("k")

b.p = f
b.v = m
l.z = k
m.p = n
m.v = b
n.z = m
f.z = k
k.p = n
k.v = b
assert n.z.p.z.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: A = None
        self.txt = txt

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

b = A("b")
l = B("l")
m = A("m")
n = B("n")
f = B("f")
k = A("k")

b.p = f
b.v = m
l.z = k
m.p = n
m.v = b
n.z = m
f.z = k
k.p = n
k.v = b
assert n.z.p.z.v.v.p.txt == "n"