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

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

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

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

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

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

j = A("j")
n = B("n")
d = C("d")
a = D("a")
i = E("i")
l = F("l")
g = C("g")
m = C("m")
e = E("e")
b = B("b")

j.p = l
n.t = a
n.w = a
n.x = a
n.u = l
n.r = b
n.q = m
d.q = n
a.q = j
i.o = b
i.r = m
i.t = e
l.w = m
g.q = b
m.q = b
e.o = n
e.r = d
e.t = i
b.t = a
b.w = a
b.x = a
b.u = l
b.r = n
b.q = d
assert d.q.t.q.p.w.q.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

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

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

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

j = A("j")
n = B("n")
d = C("d")
a = D("a")
i = E("i")
l = F("l")
g = C("g")
m = C("m")
e = E("e")
b = B("b")

j.p = l
n.t = a
n.w = a
n.x = a
n.u = l
n.r = b
n.q = m
d.q = n
a.q = j
i.o = b
i.r = m
i.t = e
l.w = m
g.q = b
m.q = b
e.o = n
e.r = d
e.t = i
b.t = a
b.w = a
b.x = a
b.u = l
b.r = n
b.q = d
assert d.q.t.q.p.w.q.q.q.r.txt == "b"