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

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

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

j = A("j")
d = B("d")
g = C("g")
c = A("c")
m = A("m")
b = B("b")
i = C("i")

j.w = i
j.p = m
j.u = d
d.p = i
g.z = b
g.q = i
g.r = c
c.w = i
c.p = j
c.u = d
m.w = i
m.p = j
m.u = b
b.p = g
i.z = b
i.q = g
i.r = j
assert j.u.p.q.z.p.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: A = None
        self.u: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
g = C("g")
c = A("c")
m = A("m")
b = B("b")
i = C("i")

j.w = i
j.p = m
j.u = d
d.p = i
g.z = b
g.q = i
g.r = c
c.w = i
c.p = j
c.u = d
m.w = i
m.p = j
m.u = b
b.p = g
i.z = b
i.q = g
i.r = j
assert j.u.p.q.z.p.r.u.txt == "d"