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

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

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

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

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

i.y = n
i.q = k
j.t = n
j.x = n
j.q = l
a.s = k
a.t = i
a.q = i
a.r = l
k.q = j
k.p = a
f.q = j
f.p = l
l.s = f
l.t = i
l.q = i
l.r = a
n.q = j
n.p = a
assert a.q.y.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

i.y = n
i.q = k
j.t = n
j.x = n
j.q = l
a.s = k
a.t = i
a.q = i
a.r = l
k.q = j
k.p = a
f.q = j
f.p = l
l.s = f
l.t = i
l.q = i
l.r = a
n.q = j
n.p = a
assert a.q.y.q.q.r.txt == "a"