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

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: D = None
        self.txt = txt

k = A("k")
b = B("b")
a = C("a")
d = D("d")
l = E("l")
h = D("h")
n = E("n")
m = E("m")

k.o = h
b.y = k
a.w = n
a.o = k
d.v = k
d.x = m
l.v = a
l.o = d
h.v = k
h.x = n
n.v = a
n.o = d
m.v = a
m.o = h
assert l.v.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: A = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: D = None
        self.txt = txt

k = A("k")
b = B("b")
a = C("a")
d = D("d")
l = E("l")
h = D("h")
n = E("n")
m = E("m")

k.o = h
b.y = k
a.w = n
a.o = k
d.v = k
d.x = m
l.v = a
l.o = d
h.v = k
h.x = n
n.v = a
n.o = d
m.v = a
m.o = h
assert l.v.o.o.txt == "h"