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

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

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

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

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

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

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

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

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

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

h.r = a
h.t = a
a.v = d
j.t = d
j.w = d
j.s = h
j.u = a
d.r = a
d.v = h
d.x = h
d.w = h
assert h.t.v.r.txt == "a"