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

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

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

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

a = A("a")
f = B("f")
g = C("g")
b = D("b")
k = D("k")
h = D("h")
m = A("m")
i = A("i")

a.v = i
f.o = i
f.u = i
f.t = g
f.v = h
g.y = a
g.t = m
g.r = f
g.o = b
b.t = g
b.x = h
k.t = g
k.x = b
h.t = g
h.x = b
m.v = i
i.v = m
assert a.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.o: A = None
        self.u: A = None
        self.t: C = None
        self.v: D = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
g = C("g")
b = D("b")
k = D("k")
h = D("h")
m = A("m")
i = A("i")

a.v = i
f.o = i
f.u = i
f.t = g
f.v = h
g.y = a
g.t = m
g.r = f
g.o = b
b.t = g
b.x = h
k.t = g
k.x = b
h.t = g
h.x = b
m.v = i
i.v = m
assert a.v.v.v.v.txt == "m"