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

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

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

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

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

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

a.q = h
c.w = i
h.w = i
g.w = k
e.q = h
d.q = h
i.q = g
k.q = c
j.w = e
assert c.w.q.w.txt == "k"