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

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

c = A("c")
m = B("m")
e = A("e")
a = B("a")
n = B("n")
g = A("g")
i = B("i")
k = A("k")

c.y = m
c.r = a
m.t = g
m.w = g
e.y = n
e.r = n
a.t = g
a.w = c
n.t = e
n.w = e
g.y = a
g.r = a
i.t = c
i.w = c
k.y = n
k.r = a
assert c.y.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.r: B = None
        self.txt = txt

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

c = A("c")
m = B("m")
e = A("e")
a = B("a")
n = B("n")
g = A("g")
i = B("i")
k = A("k")

c.y = m
c.r = a
m.t = g
m.w = g
e.y = n
e.r = n
a.t = g
a.w = c
n.t = e
n.w = e
g.y = a
g.r = a
i.t = c
i.w = c
k.y = n
k.r = a
assert c.y.w.r.txt == "a"