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

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

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

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

g = A("g")
h = B("h")
f = C("f")
k = D("k")

g.p = f
g.s = f
g.v = h
h.w = k
h.y = k
h.o = k
f.u = k
f.s = k
f.r = k
f.o = h
k.r = h
assert k.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.s: C = None
        self.v: B = None
        self.txt = txt

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

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

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

g = A("g")
h = B("h")
f = C("f")
k = D("k")

g.p = f
g.s = f
g.v = h
h.w = k
h.y = k
h.o = k
f.u = k
f.s = k
f.r = k
f.o = h
k.r = h
assert k.r.w.r.txt == "h"