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

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

l = A("l")
g = B("g")
e = A("e")
k = B("k")
i = B("i")
b = A("b")

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

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

l = A("l")
g = B("g")
e = A("e")
k = B("k")
i = B("i")
b = A("b")

l.p = k
g.p = i
e.p = k
k.p = i
i.p = g
b.p = g
assert g.p.p.p.txt == "i"