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

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

a.t = d
a.z = j
g.y = d
g.v = d
g.w = f
f.y = d
f.p = c
b.y = d
b.p = j
d.y = g
d.v = g
d.w = f
j.t = g
j.z = c
c.t = d
c.z = a
assert d.y.y.w.p.t.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: B = None
        self.v: B = None
        self.w: C = None
        self.txt = txt

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

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

a.t = d
a.z = j
g.y = d
g.v = d
g.w = f
f.y = d
f.p = c
b.y = d
b.p = j
d.y = g
d.v = g
d.w = f
j.t = g
j.z = c
c.t = d
c.z = a
assert d.y.y.w.p.t.w.p.txt == "c"