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

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

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

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

k.y = b
k.u = b
k.r = a
e.p = k
e.w = k
e.z = m
m.x = b
m.u = f
c.x = b
c.u = f
f.x = b
f.u = c
a.p = b
a.w = k
a.z = m
b.y = k
b.u = k
b.r = e
assert a.p.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.r: B = None
        self.txt = txt

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

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

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

k.y = b
k.u = b
k.r = a
e.p = k
e.w = k
e.z = m
m.x = b
m.u = f
c.x = b
c.u = f
f.x = b
f.u = c
a.p = b
a.w = k
a.z = m
b.y = k
b.u = k
b.r = e
assert a.p.r.w.r.txt == "a"