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

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

i = A("i")
c = B("c")
k = A("k")
e = A("e")
f = B("f")

i.x = e
c.p = f
k.x = i
e.x = k
f.p = c
assert i.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

i = A("i")
c = B("c")
k = A("k")
e = A("e")
f = B("f")

i.x = e
c.p = f
k.x = i
e.x = k
f.p = c
assert i.x.x.x.x.x.txt == "k"