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

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: D = None
        self.txt = txt

d = A("d")
n = B("n")
m = C("m")
f = D("f")
a = D("a")
e = D("e")
l = A("l")
i = C("i")
g = A("g")

d.w = f
n.q = l
n.v = d
m.t = i
m.p = n
m.q = n
f.v = d
f.y = e
a.v = d
a.y = e
e.v = d
e.y = f
l.w = f
i.t = m
i.p = n
i.q = n
g.w = a
assert a.y.y.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: D = None
        self.txt = txt

d = A("d")
n = B("n")
m = C("m")
f = D("f")
a = D("a")
e = D("e")
l = A("l")
i = C("i")
g = A("g")

d.w = f
n.q = l
n.v = d
m.t = i
m.p = n
m.q = n
f.v = d
f.y = e
a.v = d
a.y = e
e.v = d
e.y = f
l.w = f
i.t = m
i.p = n
i.q = n
g.w = a
assert a.y.y.y.v.txt == "d"