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

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

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

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

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

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

c.w = j
c.q = g
b.y = d
b.u = h
e.y = j
e.u = c
g.y = d
g.u = c
a.w = j
a.q = g
d.w = h
d.q = g
j.w = d
j.q = e
h.w = c
h.q = g
assert d.w.w.w.txt == "j"