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

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

j = A("j")
c = B("c")
g = A("g")
l = A("l")
k = B("k")
b = A("b")
e = A("e")
m = B("m")
f = B("f")
h = A("h")

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

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

j = A("j")
c = B("c")
g = A("g")
l = A("l")
k = B("k")
b = A("b")
e = A("e")
m = B("m")
f = B("f")
h = A("h")

j.r = b
j.w = k
c.u = g
c.y = h
g.r = e
g.w = c
l.r = j
l.w = m
k.u = l
k.y = j
b.r = g
b.w = m
e.r = l
e.w = f
m.u = b
m.y = e
f.u = b
f.y = j
h.r = e
h.w = m
assert k.u.w.y.w.txt == "f"