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

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

f = A("f")
e = B("e")
c = A("c")
l = B("l")
n = A("n")
g = A("g")
i = B("i")

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

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

f = A("f")
e = B("e")
c = A("c")
l = B("l")
n = A("n")
g = A("g")
i = B("i")

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