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

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

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

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

d = A("d")
a = B("a")
n = C("n")
c = D("c")

d.w = c
d.t = c
a.w = c
a.s = c
a.p = d
n.y = c
n.t = a
n.o = a
n.u = d
c.t = d
assert a.p.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.t: D = None
        self.txt = txt

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

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

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

d = A("d")
a = B("a")
n = C("n")
c = D("c")

d.w = c
d.t = c
a.w = c
a.s = c
a.p = d
n.y = c
n.t = a
n.o = a
n.u = d
c.t = d
assert a.p.w.t.txt == "d"