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

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

h = A("h")
e = B("e")
j = B("j")
m = B("m")
l = B("l")
c = A("c")
g = A("g")
f = A("f")
n = B("n")
a = A("a")

h.w = c
h.r = n
e.y = f
e.s = a
j.y = h
j.s = c
m.y = g
m.s = f
l.y = g
l.s = g
c.w = h
c.r = e
g.w = h
g.r = e
f.w = c
f.r = l
n.y = c
n.s = h
a.w = g
a.r = m
assert e.s.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: B = None
        self.txt = txt

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

h = A("h")
e = B("e")
j = B("j")
m = B("m")
l = B("l")
c = A("c")
g = A("g")
f = A("f")
n = B("n")
a = A("a")

h.w = c
h.r = n
e.y = f
e.s = a
j.y = h
j.s = c
m.y = g
m.s = f
l.y = g
l.s = g
c.w = h
c.r = e
g.w = h
g.r = e
f.w = c
f.r = l
n.y = c
n.s = h
a.w = g
a.r = m
assert e.s.w.r.txt == "e"