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

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

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

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

j = A("j")
f = B("f")
m = C("m")
a = D("a")
d = D("d")
c = A("c")
i = C("i")

j.p = c
j.r = c
f.o = c
f.w = m
f.v = j
m.s = i
m.z = i
m.v = c
a.p = f
d.p = f
c.p = j
c.r = j
i.s = m
i.z = m
i.v = c
assert d.p.v.r.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.r: A = None
        self.txt = txt

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

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

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

j = A("j")
f = B("f")
m = C("m")
a = D("a")
d = D("d")
c = A("c")
i = C("i")

j.p = c
j.r = c
f.o = c
f.w = m
f.v = j
m.s = i
m.z = i
m.v = c
a.p = f
d.p = f
c.p = j
c.r = j
i.s = m
i.z = m
i.v = c
assert d.p.v.r.p.p.txt == "c"