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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

g = A("g")
l = B("l")
m = C("m")
k = A("k")
n = A("n")
e = C("e")

g.w = m
g.o = e
l.p = m
m.x = e
k.w = e
k.o = m
n.w = e
n.o = m
e.x = m
assert m.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

g = A("g")
l = B("l")
m = C("m")
k = A("k")
n = A("n")
e = C("e")

g.w = m
g.o = e
l.p = m
m.x = e
k.w = e
k.o = m
n.w = e
n.o = m
e.x = m
assert m.x.x.x.x.x.txt == "e"