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

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

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

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

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

h.u = c
h.y = c
h.w = i
c.s = i
c.p = i
c.u = h
c.t = h
i.t = h
i.p = h
i.u = d
d.x = i
l.x = i
assert i.u.x.u.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: C = None
        self.y: B = None
        self.txt = txt

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

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

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

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

h.u = c
h.y = c
h.w = i
c.s = i
c.p = i
c.u = h
c.t = h
i.t = h
i.p = h
i.u = d
d.x = i
l.x = i
assert i.u.x.u.x.u.txt == "d"