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

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

i = A("i")
d = B("d")
l = A("l")
n = A("n")
g = B("g")
b = A("b")

i.x = n
d.s = g
l.x = i
n.x = l
g.s = d
b.x = l
assert i.x.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.s: B = None
        self.txt = txt

i = A("i")
d = B("d")
l = A("l")
n = A("n")
g = B("g")
b = A("b")

i.x = n
d.s = g
l.x = i
n.x = l
g.s = d
b.x = l
assert i.x.x.x.x.x.x.txt == "i"