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

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

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

f = A("f")
n = B("n")
d = C("d")
i = B("i")
a = A("a")
j = B("j")
l = C("l")

f.q = l
f.z = a
f.r = a
n.w = j
n.v = f
d.u = a
d.o = a
i.w = n
i.v = f
a.q = l
a.z = f
a.r = f
j.w = n
j.v = f
l.u = f
l.o = f
assert j.v.z.q.o.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: A = None
        self.r: A = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
d = C("d")
i = B("i")
a = A("a")
j = B("j")
l = C("l")

f.q = l
f.z = a
f.r = a
n.w = j
n.v = f
d.u = a
d.o = a
i.w = n
i.v = f
a.q = l
a.z = f
a.r = f
j.w = n
j.v = f
l.u = f
l.o = f
assert j.v.z.q.o.q.u.txt == "f"