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

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

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

n = A("n")
l = B("l")
c = C("c")
g = C("g")
e = A("e")
i = A("i")

n.q = l
n.y = g
l.x = n
l.p = i
l.u = c
c.x = n
c.u = g
g.x = n
g.u = c
e.q = l
e.y = c
i.q = l
i.y = g
assert i.y.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: C = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
c = C("c")
g = C("g")
e = A("e")
i = A("i")

n.q = l
n.y = g
l.x = n
l.p = i
l.u = c
c.x = n
c.u = g
g.x = n
g.u = c
e.q = l
e.y = c
i.q = l
i.y = g
assert i.y.u.x.txt == "n"