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

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

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

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

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

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

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