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

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

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

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

k = A("k")
c = B("c")
f = C("f")
l = D("l")
j = A("j")
d = B("d")

k.p = c
k.v = j
k.t = f
c.v = d
c.q = f
f.p = l
l.q = f
l.v = c
l.s = j
j.p = d
j.v = k
j.t = f
d.v = c
d.q = f
assert l.q.p.s.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: A = None
        self.t: C = None
        self.txt = txt

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

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

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

k = A("k")
c = B("c")
f = C("f")
l = D("l")
j = A("j")
d = B("d")

k.p = c
k.v = j
k.t = f
c.v = d
c.q = f
f.p = l
l.q = f
l.v = c
l.s = j
j.p = d
j.v = k
j.t = f
d.v = c
d.q = f
assert l.q.p.s.v.p.txt == "c"