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

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

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

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

h = A("h")
k = B("k")
c = C("c")
m = D("m")
i = C("i")
b = B("b")

h.v = k
h.u = m
h.t = m
h.s = i
k.r = b
c.q = b
m.p = h
m.u = h
m.v = c
i.q = k
b.r = k
assert i.q.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: D = None
        self.s: C = None
        self.t: D = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
c = C("c")
m = D("m")
i = C("i")
b = B("b")

h.v = k
h.u = m
h.t = m
h.s = i
k.r = b
c.q = b
m.p = h
m.u = h
m.v = c
i.q = k
b.r = k
assert i.q.r.r.r.r.txt == "k"