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

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

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

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

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

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

f.v = n
f.p = k
k.o = n
n.o = k
l.v = n
l.p = k
assert n.o.o.o.txt == "k"