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

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

d.t = i
d.u = i
d.v = n
i.t = n
i.y = n
i.u = d
n.t = d
n.v = i
n.p = i
n.w = b
b.q = d
assert d.t.t.w.txt == "b"