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

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

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

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

b = A("b")
n = B("n")
h = C("h")
a = D("a")
e = B("e")

b.v = n
b.r = h
b.z = h
n.s = b
n.p = h
h.w = b
h.q = b
h.r = n
a.t = n
a.z = h
e.s = b
e.p = h
assert h.q.v.p.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: C = None
        self.z: C = None
        self.txt = txt

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

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

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

b = A("b")
n = B("n")
h = C("h")
a = D("a")
e = B("e")

b.v = n
b.r = h
b.z = h
n.s = b
n.p = h
h.w = b
h.q = b
h.r = n
a.t = n
a.z = h
e.s = b
e.p = h
assert h.q.v.p.w.v.txt == "n"