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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: A = None
        self.x: E = None
        self.o: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: A = None
        self.r: C = None
        self.t: E = None
        self.q: A = None
        self.txt = txt

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

k = A("k")
g = B("g")
h = C("h")
b = D("b")
j = E("j")
m = E("m")
a = B("a")
l = D("l")

k.q = h
g.s = k
g.t = k
g.x = m
g.o = h
h.t = j
b.y = m
b.t = m
b.x = k
b.q = k
b.r = h
j.v = m
m.v = j
a.s = k
a.t = k
a.x = j
a.o = h
l.y = m
l.x = k
l.q = k
l.r = h
l.t = j
assert m.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.t: A = None
        self.x: E = None
        self.o: C = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: E = None
        self.x: A = None
        self.r: C = None
        self.t: E = None
        self.q: A = None
        self.txt = txt

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

k = A("k")
g = B("g")
h = C("h")
b = D("b")
j = E("j")
m = E("m")
a = B("a")
l = D("l")

k.q = h
g.s = k
g.t = k
g.x = m
g.o = h
h.t = j
b.y = m
b.t = m
b.x = k
b.q = k
b.r = h
j.v = m
m.v = j
a.s = k
a.t = k
a.x = j
a.o = h
l.y = m
l.x = k
l.q = k
l.r = h
l.t = j
assert m.v.v.v.v.v.txt == "j"