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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.w: C = None
        self.o: C = None
        self.txt = txt

d = A("d")
n = B("n")
f = C("f")
j = D("j")
m = C("m")
h = B("h")
k = B("k")

d.w = f
d.v = f
n.v = j
n.o = d
n.r = d
n.p = m
f.q = d
f.t = m
j.t = h
j.z = h
j.w = m
j.o = f
m.q = d
m.t = f
h.v = j
h.o = d
h.r = d
h.p = m
k.v = j
k.o = d
k.r = d
k.p = m
assert k.v.t.p.t.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.z: B = None
        self.w: C = None
        self.o: C = None
        self.txt = txt

d = A("d")
n = B("n")
f = C("f")
j = D("j")
m = C("m")
h = B("h")
k = B("k")

d.w = f
d.v = f
n.v = j
n.o = d
n.r = d
n.p = m
f.q = d
f.t = m
j.t = h
j.z = h
j.w = m
j.o = f
m.q = d
m.t = f
h.v = j
h.o = d
h.r = d
h.p = m
k.v = j
k.o = d
k.r = d
k.p = m
assert k.v.t.p.t.t.q.txt == "d"