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

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

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

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

l = A("l")
m = B("m")
n = C("n")
f = D("f")
e = D("e")
c = A("c")

l.y = n
m.p = n
m.y = n
m.x = c
m.s = c
n.w = e
n.p = f
n.x = c
n.z = m
f.u = m
e.u = m
c.y = n
assert m.s.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

l = A("l")
m = B("m")
n = C("n")
f = D("f")
e = D("e")
c = A("c")

l.y = n
m.p = n
m.y = n
m.x = c
m.s = c
n.w = e
n.p = f
n.x = c
n.z = m
f.u = m
e.u = m
c.y = n
assert m.s.y.x.txt == "c"