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

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

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

e = A("e")
b = B("b")
g = C("g")
c = C("c")
m = C("m")
l = A("l")
d = B("d")

e.o = c
e.q = c
e.w = l
b.q = c
b.w = d
b.s = e
g.u = l
c.u = l
m.u = e
l.o = m
l.q = c
l.w = e
d.q = m
d.w = b
d.s = l
assert g.u.o.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.q: C = None
        self.w: A = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
g = C("g")
c = C("c")
m = C("m")
l = A("l")
d = B("d")

e.o = c
e.q = c
e.w = l
b.q = c
b.w = d
b.s = e
g.u = l
c.u = l
m.u = e
l.o = m
l.q = c
l.w = e
d.q = m
d.w = b
d.s = l
assert g.u.o.u.w.txt == "l"