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

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

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

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

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

n.u = h
n.s = k
n.o = j
h.o = n
h.x = n
h.q = k
h.r = j
j.r = b
b.v = j
k.v = j
i.v = j
assert j.r.v.r.v.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: D = None
        self.o: C = None
        self.txt = txt

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

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

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

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

n.u = h
n.s = k
n.o = j
h.o = n
h.x = n
h.q = k
h.r = j
j.r = b
b.v = j
k.v = j
i.v = j
assert j.r.v.r.v.r.v.txt == "j"