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

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

j = A("j")
e = B("e")
n = A("n")
g = A("g")
d = B("d")
b = A("b")
c = A("c")
i = B("i")
h = A("h")
k = B("k")

j.z = i
j.q = k
e.q = i
e.x = n
n.z = e
n.q = e
g.z = e
g.q = e
d.q = i
d.x = h
b.z = i
b.q = d
c.z = k
c.q = e
i.q = d
i.x = b
h.z = k
h.q = k
k.q = d
k.x = b
assert i.x.q.q.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

j = A("j")
e = B("e")
n = A("n")
g = A("g")
d = B("d")
b = A("b")
c = A("c")
i = B("i")
h = A("h")
k = B("k")

j.z = i
j.q = k
e.q = i
e.x = n
n.z = e
n.q = e
g.z = e
g.q = e
d.q = i
d.x = h
b.z = i
b.q = d
c.z = k
c.q = e
i.q = d
i.x = b
h.z = k
h.q = k
k.q = d
k.x = b
assert i.x.q.q.x.z.txt == "i"