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

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

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

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

d = A("d")
c = B("c")
h = C("h")
g = D("g")

d.o = h
d.y = h
d.v = c
d.s = c
c.z = d
c.p = h
c.r = h
h.w = d
h.q = d
h.s = c
h.r = c
g.p = d
g.s = d
g.o = h
g.t = h
assert h.r.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: C = None
        self.v: B = None
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
c = B("c")
h = C("h")
g = D("g")

d.o = h
d.y = h
d.v = c
d.s = c
c.z = d
c.p = h
c.r = h
h.w = d
h.q = d
h.s = c
h.r = c
g.p = d
g.s = d
g.o = h
g.t = h
assert h.r.r.w.txt == "d"