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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: A = None
        self.s: B = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.q: D = None
        self.r: A = None
        self.s: B = None
        self.o: E = None
        self.txt = txt

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

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

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

j.q = h
k.x = l
k.o = l
k.s = l
k.q = l
k.w = h
g.q = m
g.r = j
g.s = k
g.o = l
f.x = l
l.t = g
l.x = f
l.r = j
h.q = j
m.x = l
assert k.o.t.q.x.r.q.q.txt == "j"