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

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

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

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

f.w = a
f.o = k
a.p = l
a.r = c
l.r = g
l.q = k
l.z = c
c.r = f
c.q = a
c.z = l
g.w = a
g.o = k
k.p = l
k.r = c
assert c.r.w.p.z.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.o: B = None
        self.txt = txt

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

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

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

f.w = a
f.o = k
a.p = l
a.r = c
l.r = g
l.q = k
l.z = c
c.r = f
c.q = a
c.z = l
g.w = a
g.o = k
k.p = l
k.r = c
assert c.r.w.p.z.r.w.txt == "a"