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

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

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

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

n.q = g
n.v = c
f.p = l
l.p = f
l.u = n
g.q = n
g.v = e
b.p = l
c.p = b
c.u = n
e.p = f
e.u = n
assert l.u.v.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: C = None
        self.txt = txt

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

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

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

n.q = g
n.v = c
f.p = l
l.p = f
l.u = n
g.q = n
g.v = e
b.p = l
c.p = b
c.u = n
e.p = f
e.u = n
assert l.u.v.u.v.u.txt == "n"