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

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

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

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

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

k = A("k")
j = B("j")
n = C("n")
d = D("d")
a = E("a")
i = B("i")
f = B("f")

k.q = n
k.u = a
k.v = a
j.v = a
j.q = k
n.o = a
d.r = j
d.s = k
a.o = f
i.v = a
i.q = k
f.v = a
f.q = k
assert d.r.q.v.o.q.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: E = None
        self.v: E = None
        self.txt = txt

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

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

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

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

k = A("k")
j = B("j")
n = C("n")
d = D("d")
a = E("a")
i = B("i")
f = B("f")

k.q = n
k.u = a
k.v = a
j.v = a
j.q = k
n.o = a
d.r = j
d.s = k
a.o = f
i.v = a
i.q = k
f.v = a
f.q = k
assert d.r.q.v.o.q.q.o.txt == "a"