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

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

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

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

a = A("a")
h = B("h")
f = C("f")
j = D("j")
i = C("i")
c = D("c")

a.u = h
h.r = a
f.v = i
f.z = h
j.s = a
j.u = h
i.v = f
i.z = h
c.s = a
c.u = h
assert c.u.r.u.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

a = A("a")
h = B("h")
f = C("f")
j = D("j")
i = C("i")
c = D("c")

a.u = h
h.r = a
f.v = i
f.z = h
j.s = a
j.u = h
i.v = f
i.z = h
c.s = a
c.u = h
assert c.u.r.u.r.u.txt == "h"