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

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

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

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

a = A("a")
j = B("j")
h = C("h")
c = D("c")

a.v = c
a.w = j
j.r = h
j.t = a
j.x = a
h.x = c
h.t = c
h.o = j
c.y = j
c.v = a
c.s = a
c.r = h
assert a.v.v.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.w: B = None
        self.txt = txt

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

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

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

a = A("a")
j = B("j")
h = C("h")
c = D("c")

a.v = c
a.w = j
j.r = h
j.t = a
j.x = a
h.x = c
h.t = c
h.o = j
c.y = j
c.v = a
c.s = a
c.r = h
assert a.v.v.v.y.txt == "j"