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

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

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

a = A("a")
c = B("c")
l = C("l")
f = A("f")
b = B("b")
j = C("j")
m = B("m")
k = A("k")

a.p = c
a.w = f
c.u = l
c.r = k
c.w = f
l.q = c
l.s = b
l.p = j
f.p = m
f.w = k
b.u = l
b.r = k
b.w = k
j.q = b
j.s = c
j.p = l
m.u = l
m.r = a
m.w = a
k.p = c
k.w = f
assert f.p.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: A = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
l = C("l")
f = A("f")
b = B("b")
j = C("j")
m = B("m")
k = A("k")

a.p = c
a.w = f
c.u = l
c.r = k
c.w = f
l.q = c
l.s = b
l.p = j
f.p = m
f.w = k
b.u = l
b.r = k
b.w = k
j.q = b
j.s = c
j.p = l
m.u = l
m.r = a
m.w = a
k.p = c
k.w = f
assert f.p.w.w.w.txt == "k"