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

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

f = A("f")
g = B("g")
j = B("j")
e = B("e")
i = B("i")
l = B("l")

f.q = e
g.x = l
j.x = e
e.x = g
i.x = l
l.x = j
assert l.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

f = A("f")
g = B("g")
j = B("j")
e = B("e")
i = B("i")
l = B("l")

f.q = e
g.x = l
j.x = e
e.x = g
i.x = l
l.x = j
assert l.x.x.x.x.x.x.txt == "e"