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

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

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

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

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

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

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

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

g.y = m
k.o = g
l.v = g
l.x = n
m.v = d
m.x = b
e.o = g
b.v = d
b.x = n
h.o = g
i.o = g
d.y = l
n.v = d
n.x = b
assert d.y.v.y.x.x.v.y.x.x.v.txt == "d"