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

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

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

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

g = A("g")
j = B("j")
d = C("d")
i = D("i")
f = D("f")
h = D("h")

g.t = j
g.v = d
j.x = g
j.v = g
j.o = g
j.w = i
d.q = g
d.y = h
i.p = d
i.t = h
f.p = d
f.t = h
h.p = d
h.t = i
assert f.t.p.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.txt = txt

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

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

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

g = A("g")
j = B("j")
d = C("d")
i = D("i")
f = D("f")
h = D("h")

g.t = j
g.v = d
j.x = g
j.v = g
j.o = g
j.w = i
d.q = g
d.y = h
i.p = d
i.t = h
f.p = d
f.t = h
h.p = d
h.t = i
assert f.t.p.q.v.txt == "d"