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

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

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

i.y = l
f.q = l
k.q = i
j.y = i
c.q = i
l.y = i
assert j.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

i.y = l
f.q = l
k.q = i
j.y = i
c.q = i
l.y = i
assert j.y.y.y.txt == "i"