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

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

i = A("i")
d = B("d")
e = C("e")
g = D("g")
n = B("n")
f = C("f")
a = A("a")

i.x = f
i.o = e
d.v = g
e.w = i
e.o = g
e.y = g
e.p = n
g.r = a
n.v = g
f.w = a
f.o = g
f.y = g
f.p = d
a.x = f
a.o = f
assert a.x.y.r.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

i = A("i")
d = B("d")
e = C("e")
g = D("g")
n = B("n")
f = C("f")
a = A("a")

i.x = f
i.o = e
d.v = g
e.w = i
e.o = g
e.y = g
e.p = n
g.r = a
n.v = g
f.w = a
f.o = g
f.y = g
f.p = d
a.x = f
a.o = f
assert a.x.y.r.o.y.txt == "g"