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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: D = None
        self.w: A = None
        self.o: C = None
        self.txt = txt

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

h.u = f
h.v = n
h.t = j
j.p = f
f.q = n
f.u = j
n.q = f
n.o = f
n.u = i
n.w = h
i.q = f
i.o = f
i.u = n
i.w = h
assert h.t.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.v: D = None
        self.t: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: D = None
        self.w: A = None
        self.o: C = None
        self.txt = txt

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

h.u = f
h.v = n
h.t = j
j.p = f
f.q = n
f.u = j
n.q = f
n.o = f
n.u = i
n.w = h
i.q = f
i.o = f
i.u = n
i.w = h
assert h.t.p.u.txt == "j"