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

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

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

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

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

g = A("g")
a = B("a")
j = C("j")
h = D("h")
i = E("i")
k = A("k")
m = D("m")
e = C("e")
f = B("f")

g.r = j
a.u = f
a.s = f
a.x = i
a.q = m
a.t = k
j.p = i
j.v = f
h.x = a
i.v = k
k.r = j
m.x = a
e.p = i
e.v = f
f.u = a
f.s = a
f.x = i
f.q = m
f.t = k
assert i.v.r.p.v.r.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

g = A("g")
a = B("a")
j = C("j")
h = D("h")
i = E("i")
k = A("k")
m = D("m")
e = C("e")
f = B("f")

g.r = j
a.u = f
a.s = f
a.x = i
a.q = m
a.t = k
j.p = i
j.v = f
h.x = a
i.v = k
k.r = j
m.x = a
e.p = i
e.v = f
f.u = a
f.s = a
f.x = i
f.q = m
f.t = k
assert i.v.r.p.v.r.v.q.txt == "m"