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

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

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

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

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

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

j.q = c
j.y = e
i.v = e
i.x = j
l.v = i
l.x = g
g.q = c
g.y = l
e.v = l
e.x = g
c.q = j
c.y = i
assert e.x.y.x.y.v.txt == "i"