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

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

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

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

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

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

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

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

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

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

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