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

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

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

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

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

m.u = f
f.s = i
f.t = h
h.t = m
h.v = i
h.p = i
h.x = j
j.v = f
i.t = m
i.v = h
i.p = h
i.x = j
assert j.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

m.u = f
f.s = i
f.t = h
h.t = m
h.v = i
h.p = i
h.x = j
j.v = f
i.t = m
i.v = h
i.p = h
i.x = j
assert j.v.s.v.txt == "h"