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

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

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

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

l = A("l")
a = B("a")
e = C("e")
b = D("b")
h = D("h")
k = C("k")
d = A("d")
f = D("f")

l.w = a
l.p = f
a.v = d
e.v = d
e.t = a
b.u = h
b.q = f
b.w = a
h.u = f
h.q = f
h.w = a
k.v = l
k.t = a
d.w = a
d.p = h
f.u = b
f.q = h
f.w = a
assert h.w.v.w.v.p.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: D = None
        self.txt = txt

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

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

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

l = A("l")
a = B("a")
e = C("e")
b = D("b")
h = D("h")
k = C("k")
d = A("d")
f = D("f")

l.w = a
l.p = f
a.v = d
e.v = d
e.t = a
b.u = h
b.q = f
b.w = a
h.u = f
h.q = f
h.w = a
k.v = l
k.t = a
d.w = a
d.p = h
f.u = b
f.q = h
f.w = a
assert h.w.v.w.v.p.w.v.txt == "d"