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

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

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

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

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

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

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

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

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

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

c.t = k
c.p = k
k.z = d
k.p = c
k.y = h
k.o = h
h.u = c
h.r = g
h.x = k
g.w = c
g.z = h
d.w = c
d.z = h
assert h.r.w.p.y.txt == "h"