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

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

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

e = A("e")
l = B("l")
d = C("d")
g = C("g")

e.p = l
e.w = l
e.x = l
l.q = g
l.x = e
d.x = g
d.y = g
d.o = l
g.x = d
g.y = d
g.o = l
assert d.o.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: B = None
        self.x: B = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
d = C("d")
g = C("g")

e.p = l
e.w = l
e.x = l
l.q = g
l.x = e
d.x = g
d.y = g
d.o = l
g.x = d
g.y = d
g.o = l
assert d.o.x.w.txt == "l"