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

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

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

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

d = A("d")
i = B("i")
b = C("b")
h = D("h")

d.y = b
i.y = h
i.r = b
i.t = d
i.v = d
b.v = h
b.u = h
b.p = h
b.r = i
h.r = i
h.p = d
assert b.r.t.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
b = C("b")
h = D("h")

d.y = b
i.y = h
i.r = b
i.t = d
i.v = d
b.v = h
b.u = h
b.p = h
b.r = i
h.r = i
h.p = d
assert b.r.t.y.v.txt == "h"