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

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

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

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

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

m.t = g
d.v = b
d.t = l
g.x = n
g.z = l
g.o = l
g.r = m
b.o = a
n.x = g
n.z = l
n.o = l
n.r = l
a.v = b
a.t = m
l.t = g
assert a.v.o.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

m.t = g
d.v = b
d.t = l
g.x = n
g.z = l
g.o = l
g.r = m
b.o = a
n.x = g
n.z = l
n.o = l
n.r = l
a.v = b
a.t = m
l.t = g
assert a.v.o.v.o.v.txt == "b"