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

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

n = A("n")
k = B("k")
e = A("e")

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

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

n = A("n")
k = B("k")
e = A("e")

n.o = k
k.u = n
k.p = n
e.o = k
assert n.o.p.o.txt == "k"