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

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

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

n = A("n")
g = B("g")
d = C("d")
c = C("c")
l = B("l")
f = A("f")
a = B("a")

n.p = f
n.u = d
g.s = l
g.q = l
g.u = n
d.z = n
d.v = c
d.x = f
c.z = n
c.x = n
c.v = d
l.s = a
l.u = n
l.q = g
f.p = n
f.u = c
a.s = g
a.u = n
a.q = l
assert g.u.u.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: C = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
d = C("d")
c = C("c")
l = B("l")
f = A("f")
a = B("a")

n.p = f
n.u = d
g.s = l
g.q = l
g.u = n
d.z = n
d.v = c
d.x = f
c.z = n
c.x = n
c.v = d
l.s = a
l.u = n
l.q = g
f.p = n
f.u = c
a.s = g
a.u = n
a.q = l
assert g.u.u.v.z.txt == "n"