class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
g = C("g")
h = C("h")
b = C("b")
l = A("l")
d = C("d")
j = B("j")

n.w = j
a.q = j
a.u = n
g.z = l
g.v = l
g.r = n
h.z = n
h.r = n
h.v = l
b.z = n
b.v = n
b.r = l
l.w = a
d.z = n
d.r = l
d.v = l
j.q = a
j.u = l
assert n.w.q.q.q.q.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
g = C("g")
h = C("h")
b = C("b")
l = A("l")
d = C("d")
j = B("j")

n.w = j
a.q = j
a.u = n
g.z = l
g.v = l
g.r = n
h.z = n
h.r = n
h.v = l
b.z = n
b.v = n
b.r = l
l.w = a
d.z = n
d.r = l
d.v = l
j.q = a
j.u = l
assert n.w.q.q.q.q.u.w.q.txt == "j"