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

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

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

n = A("n")
i = B("i")
e = C("e")
j = C("j")
a = A("a")
g = B("g")

n.u = i
n.q = a
n.x = g
i.t = g
i.p = g
i.q = a
e.u = i
e.x = j
j.u = g
j.x = e
a.u = i
a.q = n
a.x = g
g.t = i
g.p = i
g.q = a
assert g.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: A = None
        self.x: B = None
        self.txt = txt

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

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

n = A("n")
i = B("i")
e = C("e")
j = C("j")
a = A("a")
g = B("g")

n.u = i
n.q = a
n.x = g
i.t = g
i.p = g
i.q = a
e.u = i
e.x = j
j.u = g
j.x = e
a.u = i
a.q = n
a.x = g
g.t = i
g.p = i
g.q = a
assert g.q.q.q.txt == "a"