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

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

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

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

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

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

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

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

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

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

l.t = m
b.v = i
b.y = g
b.o = m
d.t = b
m.x = b
c.t = i
i.v = a
i.y = g
i.o = m
a.v = i
a.y = g
a.o = m
g.t = m
assert i.v.v.o.x.o.x.v.o.txt == "m"