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

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

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

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

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

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

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

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

n.w = d
j.t = i
a.x = n
a.v = d
a.p = d
g.x = i
g.v = j
g.p = d
d.t = n
f.x = i
f.v = j
f.p = d
c.x = i
c.v = j
c.p = d
i.w = j
assert j.t.w.t.w.t.w.t.w.txt == "j"