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

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

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

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

d = A("d")
m = B("m")
h = C("h")
c = D("c")
f = A("f")
j = A("j")
i = D("i")

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

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

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

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

d = A("d")
m = B("m")
h = C("h")
c = D("c")
f = A("f")
j = A("j")
i = D("i")

d.t = f
m.w = i
m.u = h
m.x = c
h.u = j
h.r = m
c.v = h
c.t = f
c.x = i
c.s = m
f.t = j
j.t = d
i.v = h
i.t = f
i.x = c
i.s = m
assert d.t.t.t.txt == "d"