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

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

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

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

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

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

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

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

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

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

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