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.w: B = None
        self.o: A = None
        self.txt = txt

j = A("j")
a = B("a")
g = B("g")
c = A("c")
e = B("e")
f = B("f")
l = A("l")
i = B("i")

j.r = l
j.w = f
a.w = e
a.o = l
g.w = i
g.o = l
c.r = j
c.w = f
e.w = i
e.o = j
f.w = a
f.o = c
l.r = c
l.w = e
i.w = g
i.o = l
assert c.w.w.w.w.w.o.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.w: B = None
        self.o: A = None
        self.txt = txt

j = A("j")
a = B("a")
g = B("g")
c = A("c")
e = B("e")
f = B("f")
l = A("l")
i = B("i")

j.r = l
j.w = f
a.w = e
a.o = l
g.w = i
g.o = l
c.r = j
c.w = f
e.w = i
e.o = j
f.w = a
f.o = c
l.r = c
l.w = e
i.w = g
i.o = l
assert c.w.w.w.w.w.o.txt == "l"