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

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

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

f = A("f")
a = B("a")
j = C("j")
m = A("m")
c = B("c")
l = C("l")
e = B("e")
n = C("n")

f.p = j
a.r = m
a.x = n
a.q = n
j.q = l
j.t = l
m.p = l
c.r = m
c.x = j
c.q = l
l.q = n
l.t = n
e.r = f
e.x = l
e.q = l
n.q = j
n.t = l
assert j.t.t.q.t.t.q.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

f = A("f")
a = B("a")
j = C("j")
m = A("m")
c = B("c")
l = C("l")
e = B("e")
n = C("n")

f.p = j
a.r = m
a.x = n
a.q = n
j.q = l
j.t = l
m.p = l
c.r = m
c.x = j
c.q = l
l.q = n
l.t = n
e.r = f
e.x = l
e.q = l
n.q = j
n.t = l
assert j.t.t.q.t.t.q.q.t.txt == "n"