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

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

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

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

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

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

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

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

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

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

a.o = g
a.p = f
a.x = k
a.w = k
k.r = a
k.o = g
k.v = f
d.u = g
f.t = k
f.p = k
f.y = g
h.u = f
g.t = k
g.p = k
g.y = f
assert k.o.p.o.y.y.txt == "g"