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

class B:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: E = None
        self.r: A = None
        self.u: E = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
d = C("d")
h = D("h")
b = E("b")
i = A("i")
m = E("m")

j.v = i
k.q = m
k.x = m
k.r = i
k.u = b
d.w = i
h.u = d
b.y = i
b.o = h
i.v = j
m.y = i
m.o = h
assert d.w.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.q: E = None
        self.x: E = None
        self.r: A = None
        self.u: E = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
d = C("d")
h = D("h")
b = E("b")
i = A("i")
m = E("m")

j.v = i
k.q = m
k.x = m
k.r = i
k.u = b
d.w = i
h.u = d
b.y = i
b.o = h
i.v = j
m.y = i
m.o = h
assert d.w.v.v.v.txt == "j"