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

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

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

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

l = A("l")
f = B("f")
n = C("n")
k = D("k")
j = A("j")
g = C("g")
i = D("i")

l.r = f
f.q = k
n.z = j
n.v = f
k.t = i
k.p = l
j.r = f
g.z = l
g.v = f
i.t = k
i.p = j
assert n.v.q.p.r.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

l = A("l")
f = B("f")
n = C("n")
k = D("k")
j = A("j")
g = C("g")
i = D("i")

l.r = f
f.q = k
n.z = j
n.v = f
k.t = i
k.p = l
j.r = f
g.z = l
g.v = f
i.t = k
i.p = j
assert n.v.q.p.r.q.p.txt == "l"