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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.u: D = None
        self.v: D = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
j = C("j")
h = D("h")
e = B("e")

c.v = d
d.z = c
d.t = c
d.u = h
d.v = h
j.w = d
h.u = j
h.p = d
e.z = c
e.t = c
e.u = h
e.v = h
assert c.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.t: A = None
        self.u: D = None
        self.v: D = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
j = C("j")
h = D("h")
e = B("e")

c.v = d
d.z = c
d.t = c
d.u = h
d.v = h
j.w = d
h.u = j
h.p = d
e.z = c
e.t = c
e.u = h
e.v = h
assert c.v.z.v.txt == "d"