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

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

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

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

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

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

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

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

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

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

h.v = j
h.r = j
h.y = j
h.t = b
j.z = a
b.t = j
a.o = h
a.u = h
a.x = b
assert a.x.t.z.txt == "a"