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

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

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

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

c = A("c")
m = B("m")
h = C("h")
e = D("e")

c.y = h
m.w = h
m.t = h
m.y = c
m.s = c
h.v = e
h.u = c
h.y = m
e.s = c
assert c.y.u.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

c = A("c")
m = B("m")
h = C("h")
e = D("e")

c.y = h
m.w = h
m.t = h
m.y = c
m.s = c
h.v = e
h.u = c
h.y = m
e.s = c
assert c.y.u.y.y.txt == "m"