class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.v: D = None
        self.p: C = None
        self.t: E = None
        self.txt = txt

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

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

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

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

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

j.q = f
j.t = f
j.v = g
j.p = m
k.r = g
k.x = g
k.t = i
i.v = m
g.p = l
g.s = f
g.q = j
g.o = k
l.q = k
l.p = m
l.y = j
f.q = k
f.p = i
f.y = j
m.v = i
assert g.q.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.v: D = None
        self.p: C = None
        self.t: E = None
        self.txt = txt

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

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

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

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

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

j.q = f
j.t = f
j.v = g
j.p = m
k.r = g
k.x = g
k.t = i
i.v = m
g.p = l
g.s = f
g.q = j
g.o = k
l.q = k
l.p = m
l.y = j
f.q = k
f.p = i
f.y = j
m.v = i
assert g.q.t.p.txt == "i"