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

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

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

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

g = A("g")
h = B("h")
m = C("m")
e = D("e")
j = B("j")
l = B("l")
i = A("i")
k = B("k")
d = A("d")
a = D("a")

g.v = i
h.x = e
m.y = d
m.u = g
e.v = d
e.r = m
e.o = h
e.w = a
j.x = e
l.x = e
i.v = g
k.x = e
d.v = i
a.v = d
a.r = m
a.o = k
a.w = e
assert g.v.v.v.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
m = C("m")
e = D("e")
j = B("j")
l = B("l")
i = A("i")
k = B("k")
d = A("d")
a = D("a")

g.v = i
h.x = e
m.y = d
m.u = g
e.v = d
e.r = m
e.o = h
e.w = a
j.x = e
l.x = e
i.v = g
k.x = e
d.v = i
a.v = d
a.r = m
a.o = k
a.w = e
assert g.v.v.v.v.v.v.v.v.v.txt == "i"