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

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

c = A("c")
g = B("g")
k = B("k")
b = A("b")
i = B("i")

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

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

c = A("c")
g = B("g")
k = B("k")
b = A("b")
i = B("i")

c.p = b
g.x = k
k.x = g
b.p = c
i.x = g
assert b.p.p.p.p.p.txt == "c"