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

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

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

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

b = A("b")
m = B("m")
a = C("a")
d = D("d")
g = B("g")
i = A("i")

b.x = g
b.z = d
m.y = a
m.u = a
m.v = i
m.x = g
a.o = m
d.y = m
d.v = a
d.x = g
g.y = a
g.u = a
g.v = i
g.x = m
i.x = g
i.z = d
assert m.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: D = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
a = C("a")
d = D("d")
g = B("g")
i = A("i")

b.x = g
b.z = d
m.y = a
m.u = a
m.v = i
m.x = g
a.o = m
d.y = m
d.v = a
d.x = g
g.y = a
g.u = a
g.v = i
g.x = m
i.x = g
i.z = d
assert m.y.o.y.txt == "a"