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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

j = A("j")
h = B("h")
g = C("g")
i = D("i")
k = E("k")
b = F("b")
c = B("c")
n = C("n")
f = D("f")
m = A("m")

j.p = g
j.o = m
j.q = m
h.v = g
h.q = j
h.y = k
g.q = b
i.q = b
k.u = n
b.s = k
c.v = g
c.q = j
c.y = k
n.q = b
f.q = b
m.p = g
m.o = j
m.q = j
assert f.q.s.u.q.s.u.q.s.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.o: A = None
        self.q: A = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

j = A("j")
h = B("h")
g = C("g")
i = D("i")
k = E("k")
b = F("b")
c = B("c")
n = C("n")
f = D("f")
m = A("m")

j.p = g
j.o = m
j.q = m
h.v = g
h.q = j
h.y = k
g.q = b
i.q = b
k.u = n
b.s = k
c.v = g
c.q = j
c.y = k
n.q = b
f.q = b
m.p = g
m.o = j
m.q = j
assert f.q.s.u.q.s.u.q.s.u.q.txt == "b"