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

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

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

d = A("d")
i = B("i")
h = C("h")
l = C("l")
g = A("g")
k = C("k")
f = A("f")
b = A("b")
e = B("e")

d.w = h
d.r = i
i.y = d
h.o = i
h.v = i
l.o = e
l.v = e
g.w = l
g.r = e
k.o = i
k.v = e
f.w = h
f.r = i
b.w = h
b.r = e
e.y = d
assert g.w.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: B = None
        self.txt = txt

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

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

d = A("d")
i = B("i")
h = C("h")
l = C("l")
g = A("g")
k = C("k")
f = A("f")
b = A("b")
e = B("e")

d.w = h
d.r = i
i.y = d
h.o = i
h.v = i
l.o = e
l.v = e
g.w = l
g.r = e
k.o = i
k.v = e
f.w = h
f.r = i
b.w = h
b.r = e
e.y = d
assert g.w.o.y.txt == "d"