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

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

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

g = A("g")
c = B("c")
b = C("b")
a = B("a")
k = C("k")
d = A("d")

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

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

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

g = A("g")
c = B("c")
b = C("b")
a = B("a")
k = C("k")
d = A("d")

g.z = a
g.w = c
g.u = d
c.r = g
c.y = a
c.x = b
b.x = k
b.q = g
b.p = g
a.r = g
a.y = c
a.x = k
k.x = b
k.q = g
k.p = d
d.z = c
d.w = a
d.u = g
assert d.z.r.z.r.txt == "g"