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

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

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

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

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

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

k.y = l
k.o = e
e.p = k
l.p = k
assert k.o.p.o.txt == "e"