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

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

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

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

l = A("l")
k = B("k")
n = C("n")
c = D("c")
d = C("d")
a = A("a")
g = C("g")

l.p = c
k.s = a
k.v = l
n.w = c
n.t = k
n.p = a
n.z = a
c.r = a
c.t = k
d.w = c
d.t = k
d.p = l
d.z = a
a.p = c
g.w = c
g.t = k
g.p = l
g.z = a
assert l.p.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

l = A("l")
k = B("k")
n = C("n")
c = D("c")
d = C("d")
a = A("a")
g = C("g")

l.p = c
k.s = a
k.v = l
n.w = c
n.t = k
n.p = a
n.z = a
c.r = a
c.t = k
d.w = c
d.t = k
d.p = l
d.z = a
a.p = c
g.w = c
g.t = k
g.p = l
g.z = a
assert l.p.t.s.txt == "a"