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

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

a = A("a")
j = B("j")
c = B("c")
l = A("l")
h = A("h")
g = B("g")
b = A("b")

a.z = j
a.w = g
j.v = c
j.q = l
c.v = g
c.q = l
l.z = c
l.w = g
h.z = j
h.w = c
g.v = c
g.q = h
b.z = c
b.w = j
assert c.q.w.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

a = A("a")
j = B("j")
c = B("c")
l = A("l")
h = A("h")
g = B("g")
b = A("b")

a.z = j
a.w = g
j.v = c
j.q = l
c.v = g
c.q = l
l.z = c
l.w = g
h.z = j
h.w = c
g.v = c
g.q = h
b.z = c
b.w = j
assert c.q.w.v.q.txt == "l"