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

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

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

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

a = A("a")
e = B("e")
g = C("g")
l = D("l")
f = C("f")
c = C("c")
j = A("j")

a.p = l
e.s = l
g.o = f
g.z = f
g.r = a
g.w = j
l.w = c
l.r = e
f.o = g
f.r = j
f.w = j
f.z = c
c.o = g
c.r = a
c.w = a
c.z = f
j.p = l
assert f.r.p.r.s.w.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.txt = txt

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

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

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

a = A("a")
e = B("e")
g = C("g")
l = D("l")
f = C("f")
c = C("c")
j = A("j")

a.p = l
e.s = l
g.o = f
g.z = f
g.r = a
g.w = j
l.w = c
l.r = e
f.o = g
f.r = j
f.w = j
f.z = c
c.o = g
c.r = a
c.w = a
c.z = f
j.p = l
assert f.r.p.r.s.w.o.o.txt == "f"