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

l = A("l")
i = B("i")
b = A("b")
n = A("n")
f = B("f")

l.x = b
i.p = f
b.x = n
n.x = b
f.p = i
assert n.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

l = A("l")
i = B("i")
b = A("b")
n = A("n")
f = B("f")

l.x = b
i.p = f
b.x = n
n.x = b
f.p = i
assert n.x.x.x.txt == "b"