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

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

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

i.x = j
c.q = j
l.x = i
j.x = i
n.x = i
e.q = i
k.q = l
f.q = i
assert i.x.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.q: A = None
        self.txt = txt

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

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