class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: D = None
        self.x: B = None
        self.s: 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.w: A = None
        self.o: A = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
j = B("j")
l = C("l")
i = D("i")
k = B("k")
e = D("e")

d.p = k
d.x = k
d.t = e
d.s = j
j.t = d
l.w = d
l.o = d
l.v = d
i.o = e
i.q = l
k.t = d
e.o = i
e.q = l
assert e.q.o.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: D = None
        self.x: B = None
        self.s: 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.w: A = None
        self.o: A = None
        self.v: A = None
        self.txt = txt

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

d = A("d")
j = B("j")
l = C("l")
i = D("i")
k = B("k")
e = D("e")

d.p = k
d.x = k
d.t = e
d.s = j
j.t = d
l.w = d
l.o = d
l.v = d
i.o = e
i.q = l
k.t = d
e.o = i
e.q = l
assert e.q.o.p.t.txt == "d"