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

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

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

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

b.x = e
b.r = m
b.w = d
e.o = d
e.r = d
e.v = c
c.o = m
c.s = m
c.y = e
m.o = c
m.s = c
m.y = e
d.x = e
d.r = m
d.w = b
assert b.w.r.y.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: C = None
        self.w: A = None
        self.txt = txt

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

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

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

b.x = e
b.r = m
b.w = d
e.o = d
e.r = d
e.v = c
c.o = m
c.s = m
c.y = e
m.o = c
m.s = c
m.y = e
d.x = e
d.r = m
d.w = b
assert b.w.r.y.o.x.txt == "e"