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

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

i = A("i")
g = B("g")
l = A("l")
a = B("a")
j = A("j")
n = B("n")
m = B("m")

i.q = m
i.z = j
g.x = i
g.s = l
l.q = n
l.z = i
a.x = j
a.s = l
j.q = m
j.z = l
n.x = l
n.s = i
m.x = l
m.s = i
assert j.z.z.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: A = None
        self.txt = txt

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

i = A("i")
g = B("g")
l = A("l")
a = B("a")
j = A("j")
n = B("n")
m = B("m")

i.q = m
i.z = j
g.x = i
g.s = l
l.q = n
l.z = i
a.x = j
a.s = l
j.q = m
j.z = l
n.x = l
n.s = i
m.x = l
m.s = i
assert j.z.z.q.x.txt == "l"