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

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

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

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

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

h.y = c
h.o = b
h.r = j
b.v = c
c.s = j
i.t = b
i.z = b
j.y = c
j.o = b
j.r = h
assert b.v.s.o.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.o: B = None
        self.r: A = None
        self.txt = txt

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

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

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

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

h.y = c
h.o = b
h.r = j
b.v = c
c.s = j
i.t = b
i.z = b
j.y = c
j.o = b
j.r = h
assert b.v.s.o.v.s.txt == "j"