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

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

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

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

k = A("k")
d = B("d")
j = C("j")
h = D("h")

k.y = j
k.r = d
d.w = h
d.v = h
j.q = d
j.y = h
j.p = h
j.t = k
h.p = d
assert k.r.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: B = None
        self.txt = txt

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

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

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

k = A("k")
d = B("d")
j = C("j")
h = D("h")

k.y = j
k.r = d
d.w = h
d.v = h
j.q = d
j.y = h
j.p = h
j.t = k
h.p = d
assert k.r.v.p.v.txt == "h"