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

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

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

c.o = b
c.r = g
e.w = g
e.o = l
a.o = g
a.r = g
g.o = b
g.r = b
b.o = c
b.r = a
f.w = c
f.o = e
l.w = a
l.o = e
assert l.w.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: A = None
        self.txt = txt

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

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

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