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

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

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

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

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

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

k.o = e
n.y = g
e.o = k
g.y = n
assert g.y.y.y.txt == "n"