class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: A = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
a = C("a")
g = D("g")
d = A("d")
l = A("l")

j.z = a
j.p = l
f.t = g
f.s = l
a.p = g
a.w = g
a.t = j
a.q = j
g.y = f
d.z = a
d.p = l
l.z = a
l.p = d
assert d.z.q.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: A = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
a = C("a")
g = D("g")
d = A("d")
l = A("l")

j.z = a
j.p = l
f.t = g
f.s = l
a.p = g
a.w = g
a.t = j
a.q = j
g.y = f
d.z = a
d.p = l
l.z = a
l.p = d
assert d.z.q.p.p.txt == "d"